From ed5ff16598b6c47ecbc94b190eedb07b07b28a2b Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Tue, 6 Feb 2018 02:00:32 +0200 Subject: [PATCH] Downloader: clean a bit downloader::get_episode function. --- hammond-downloader/src/downloader.rs | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/hammond-downloader/src/downloader.rs b/hammond-downloader/src/downloader.rs index 53851aa..cb2a94a 100644 --- a/hammond-downloader/src/downloader.rs +++ b/hammond-downloader/src/downloader.rs @@ -172,29 +172,24 @@ pub fn get_episode( ep.save()?; }; - let res = download_into( + let path = download_into( download_folder, &ep.rowid().to_string(), ep.uri().unwrap(), progress, - ); + )?; - if let Ok(path) = res { - // If download succedes set episode local_uri to dlpath. - ep.set_local_uri(Some(&path)); + // If download succedes set episode local_uri to dlpath. + ep.set_local_uri(Some(&path)); - // Over-write episode lenght - let size = fs::metadata(path); - if let Ok(s) = size { - ep.set_length(Some(s.len() as i32)) - }; + // Over-write episode lenght + let size = fs::metadata(path); + if let Ok(s) = size { + ep.set_length(Some(s.len() as i32)) + }; - ep.save()?; - Ok(()) - } else { - error!("Something whent wrong while downloading."); - Err(res.unwrap_err()) - } + ep.save()?; + Ok(()) } pub fn cache_image(pd: &PodcastCoverQuery) -> Option {