print playlist cache parsing errors

This commit is contained in:
Henrik Friedrichsen
2019-03-17 16:10:20 +01:00
parent 98038e2cd1
commit 114fe0edb8

View File

@@ -48,16 +48,19 @@ impl Playlists {
cache_path.to_str().unwrap()
);
let parsed: Result<PlaylistStore, _> = serde_json::from_str(&contents);
if let Ok(cache) = parsed {
debug!("playlist cache loaded ({} lists)", cache.playlists.len());
let mut store = self.store.write().expect("can't writelock playlist store");
store.playlists.clear();
store.playlists.extend(cache.playlists);
match parsed {
Ok(cache) => {
debug!("playlist cache loaded ({} lists)", cache.playlists.len());
let mut store = self.store.write().expect("can't writelock playlist store");
store.playlists.clear();
store.playlists.extend(cache.playlists);
// force refresh of UI (if visible)
self.ev.send(Event::ScreenChange("playlists".to_owned()));
} else {
error!("playlist cache corrupted?");
// force refresh of UI (if visible)
self.ev.send(Event::ScreenChange("playlists".to_owned()));
},
Err(e) => {
error!("can't parse playlist cache: {}", e);
}
}
}
}