Downloader: clean a bit downloader::get_episode function.

This commit is contained in:
Jordan Petridis 2018-02-06 02:00:32 +02:00
parent c1ecdbda52
commit ed5ff16598
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6

View File

@ -172,29 +172,24 @@ pub fn get_episode(
ep.save()?; ep.save()?;
}; };
let res = download_into( let path = download_into(
download_folder, download_folder,
&ep.rowid().to_string(), &ep.rowid().to_string(),
ep.uri().unwrap(), ep.uri().unwrap(),
progress, progress,
); )?;
if let Ok(path) = res { // If download succedes set episode local_uri to dlpath.
// If download succedes set episode local_uri to dlpath. ep.set_local_uri(Some(&path));
ep.set_local_uri(Some(&path));
// Over-write episode lenght // Over-write episode lenght
let size = fs::metadata(path); let size = fs::metadata(path);
if let Ok(s) = size { if let Ok(s) = size {
ep.set_length(Some(s.len() as i32)) ep.set_length(Some(s.len() as i32))
}; };
ep.save()?; ep.save()?;
Ok(()) Ok(())
} else {
error!("Something whent wrong while downloading.");
Err(res.unwrap_err())
}
} }
pub fn cache_image(pd: &PodcastCoverQuery) -> Option<String> { pub fn cache_image(pd: &PodcastCoverQuery) -> Option<String> {