Skip to content

Commit 3fb8d65

Browse files
FranciscoTGouveiarami3l
authored andcommitted
fix(downloads): correct faulty output when retrying a download
The `DownloadFinished` notification was always being called even if the download was unsuccessful. This would confuse the DownloadTracker as to the download really ended (successfully). To fix this, the notification is now only thrown iff the download didn't timeout. This could be (possibly) accompanied by a new notification, say `DownloadTimedOut` but it wouldn't have any direct use yet, so I refrain from adding it.
1 parent fc0a76b commit 3fb8d65

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/cli/download_tracker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl DownloadTracker {
5959
self.create_progress_bar(component.to_owned(), url.to_owned());
6060
true
6161
}
62+
Notification::Install(In::RetryingDownload(_url)) => true,
6263
_ => false,
6364
}
6465
}

src/download/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ async fn download_file_(
218218
.download_to_path(url, path, resume_from_partial, Some(callback), timeout)
219219
.await;
220220

221-
notify_handler(Notification::DownloadFinished(Some(url.as_str())));
221+
// The notification should only be sent if the download was successful (i.e. didn't timeout)
222+
if res.is_ok() {
223+
notify_handler(Notification::DownloadFinished(Some(url.as_str())));
224+
}
222225

223226
res
224227
}

0 commit comments

Comments
 (0)