stop downloads when removed

This commit is contained in:
SpikeHD
2022-05-12 22:25:07 -07:00
parent 853ab1ea80
commit 5126f89d8b
3 changed files with 9 additions and 4 deletions

View File

@@ -50,6 +50,11 @@ pub async fn download_file(window: tauri::Window, url: &str, path: &str) -> Resu
// Await chunks
while let Some(item) = stream.next().await {
// Stop the loop if the download is removed from the list
if !DOWNLOADS.lock().unwrap().contains(&path.to_string()) {
break;
}
let chunk = match item {
Ok(itm) => itm,
Err(e) => {