Downloader: Change cache_image function to return Result<T, DownlaoderError> instead of Option<T>.

This commit is contained in:
Jordan Petridis
2018-02-06 20:14:03 +02:00
parent d3f279374a
commit c6e426cbac
4 changed files with 33 additions and 24 deletions
+2 -2
View File
@@ -122,9 +122,9 @@ impl App {
match receiver.recv_timeout(Duration::from_millis(10)) {
Ok(Action::UpdateSources(source)) => {
if let Some(s) = source {
utils::refresh_feed(Some(vec![s]), sender.clone())
utils::refresh_feed(Some(vec![s]), sender.clone());
} else {
utils::refresh_feed(None, sender.clone())
utils::refresh_feed(None, sender.clone());
}
}
Ok(Action::RefreshAllViews) => content.update(),
+2 -1
View File
@@ -1,5 +1,6 @@
#![cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
use failure::Error;
use gdk_pixbuf::Pixbuf;
use send_cell::SendCell;
@@ -82,7 +83,7 @@ pub fn get_pixbuf_from_path(pd: &PodcastCoverQuery, size: u32) -> Option<Pixbuf>
}
}
let img_path = downloader::cache_image(pd)?;
let img_path = downloader::cache_image(pd).ok()?;
let px = Pixbuf::new_from_file_at_scale(&img_path, size as i32, size as i32, true).ok();
if let Some(px) = px {
let mut hashmap = CACHED_PIXBUFS.write().unwrap();