Skip to content

Fix resumed download average speed#1887

Open
ishaanlabs-gg wants to merge 1 commit into
httpie:masterfrom
ishaanlabs-gg:fix-resumed-download-average-speed
Open

Fix resumed download average speed#1887
ishaanlabs-gg wants to merge 1 commit into
httpie:masterfrom
ishaanlabs-gg:fix-resumed-download-average-speed

Conversation

@ishaanlabs-gg

Copy link
Copy Markdown

Fixes #1516.

When resuming a download, the progress task starts at the existing byte offset. The completion summary was using that cumulative completed byte count for both:

  • the displayed total downloaded amount, and
  • the numerator for average speed.

That made resumed downloads report speed as if the already-present bytes were downloaded during the current invocation.

This change keeps the displayed total size cumulative, but subtracts the starting offset when calculating average speed. It applies to both the progress-bar display and the status display.

Validation:

  • First verified the new regression failed before the fix with 2.5 bytes/s for a resumed 2-byte transfer over 2 seconds.
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 /Volumes/STOREJET/2/Dependencies/httpie/venv/bin/python -m pytest tests/test_downloads.py::TestDownloads::test_resumed_download_summary_uses_current_transfer_for_speed -q
  • git diff --check

Note:

  • I installed the package and minimal focused test dependencies in /Volumes/STOREJET/2/Dependencies/httpie/venv.
  • Installing the full .[test] extra is currently blocked locally by an old transitive flasgger wheel build failure through pytest-httpbin/httpbin, so I could not run the httpbin-backed download tests in this environment.

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.

Average speed is reported incorrectly for resumed downloads

1 participant