Utils: do not block the cover_dl registry
Accidently after f21398357b when a download would start,
it would lock the cover_dl_registry hashmap till it had finished.
Since the registry.read() happens on the main thread this would
cause the UI to block until the download was and the mutex guard
from the download thread dropped.
This commit is contained in:
parent
132e2afce0
commit
822deb2867
@ -288,9 +288,14 @@ pub(crate) fn set_image_from_path(
|
||||
THREADPOOL.spawn(move || {
|
||||
if let Ok(mut guard) = COVER_DL_REGISTRY.write() {
|
||||
guard.insert(show_id);
|
||||
if let Ok(pd) = dbqueries::get_podcast_cover_from_id(show_id) {
|
||||
sender.send(downloader::cache_image(&pd));
|
||||
}
|
||||
}
|
||||
|
||||
// This operation is polling and will block the thread till the download is finished
|
||||
if let Ok(pd) = dbqueries::get_podcast_cover_from_id(show_id) {
|
||||
sender.send(downloader::cache_image(&pd));
|
||||
}
|
||||
|
||||
if let Ok(mut guard) = COVER_DL_REGISTRY.write() {
|
||||
guard.remove(&show_id);
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user