Commit 822deb28 authored by Jordan Petridis's avatar Jordan Petridis 🌱 Committed by Jordan Petridis

Utils: do not block the cover_dl registry

Accidently after f2139835 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.
parent 132e2afc
......@@ -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);
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment