Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix average download speed (httpie#1516) #1518

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mikurei
Copy link

@mikurei mikurei commented Jul 14, 2023

Problem

When DownloadStatus is finished, it calls ProgressDisplay.stop(), which in turn calls ProgressDisplay._print_summary()

Here, in _print_summary(), we incorrectly assume that task.completed means observed steps, but in fact, when the download finishes, it is equal to task.total, which leads to issue with incorrect average download speed - no matter where we resume the download process, we always get task.total steps

Solution

  • Extend the ProgressDisplay class by adding a resumed_at attribute to keep track of the progress that has already been done.
  • Change the ProgressDisplay.stop() method to pass task.completed - self.resumed_at instead of task.completed

Related

Solves the issue #1516

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.26%. Comparing base (4d7d6b6) to head (939e774).
Report is 372 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1518      +/-   ##
==========================================
- Coverage   97.28%   94.26%   -3.02%     
==========================================
  Files          67      113      +46     
  Lines        4235     7696    +3461     
==========================================
+ Hits         4120     7255    +3135     
- Misses        115      441     +326     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants