summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2025-03-04 10:10:43 +0100
committerDavid Lönnhager <david.l@mullvad.net>2025-03-05 23:32:55 +0100
commit753f73c7aa6e65f87fed312c1cf687c43d19a6c9 (patch)
tree6dfa72504c49020870ffef3831b8457c3dbcbdf4
parent9c5ed68434cd10c75fdbb3788accf86f54376b22 (diff)
downloadmullvadvpn-753f73c7aa6e65f87fed312c1cf687c43d19a6c9.tar.xz
mullvadvpn-753f73c7aa6e65f87fed312c1cf687c43d19a6c9.zip
Abort download task when begin_download is incorrectly called twice
-rw-r--r--installer-downloader/src/controller.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/installer-downloader/src/controller.rs b/installer-downloader/src/controller.rs
index 94c15de36d..7b6abce60c 100644
--- a/installer-downloader/src/controller.rs
+++ b/installer-downloader/src/controller.rs
@@ -323,9 +323,7 @@ impl<D: AppDelegate + 'static, A: From<UiAppDownloaderParameters<D>> + AppDownlo
}
async fn begin_download(&mut self) {
- if self.active_download.take().is_some() {
- log::debug!("Interrupting ongoing download");
- }
+ self.cancel_download().await;
let Some(version_info) = self.version_info.clone() else {
log::error!("Attempted 'begin download' before having version info");
return;
@@ -410,10 +408,7 @@ impl<D: AppDelegate + 'static, A: From<UiAppDownloaderParameters<D>> + AppDownlo
}
async fn cancel(&mut self) {
- if let Some(active_download) = self.active_download.take() {
- active_download.abort();
- let _ = active_download.await;
- }
+ self.cancel_download().await;
let Some(version_info) = self.version_info.as_ref() else {
log::error!("Attempted 'cancel' before having version info");
@@ -448,6 +443,14 @@ impl<D: AppDelegate + 'static, A: From<UiAppDownloaderParameters<D>> + AppDownlo
self_.clear_download_progress();
});
}
+
+ async fn cancel_download(&mut self) {
+ if let Some(active_download) = self.active_download.take() {
+ log::debug!("Interrupting ongoing download");
+ active_download.abort();
+ let _ = active_download.await;
+ }
+ }
}
/// Select a mirror to download from