Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cli/download_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl DownloadTracker {
/// Sets the length for a new ProgressBar and gives it a style.
pub(crate) fn content_length_received(&mut self, content_len: u64, url: &str) {
if let Some(pb) = self.file_progress_bars.get(url) {
pb.reset();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still useful that we're building the ProgressBar for DownloadingComponent, rather than starting at DownloadContentLengthReceived?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is justifiable since we don’t have access to the component’s name when creating a DownloadContentLengthReceived notification -- only the URL.

With that in mind, and wishing to avoid parsing the URL to extract the component’s name, I think it’s best to keep the creation of the ProgressBar within the DownloadingComponent notification.

Additionally, I’d like to note that when retrying a download, the DownloadingComponent notification is not sent again. Moving the creation of the ProgressBar to the DownloadContentLengthReceived notification could complicate the logic in the DownloadTracker, particularly when handling download retries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, I’d like to add that creating the ProgressBar within DownloadingComponent is the only way to ensure the output remains in the correct order when handling concurrent downloads.

pb.set_length(content_len);
}
}
Expand Down
Loading