cli icon indicating copy to clipboard operation
cli copied to clipboard

Fix average download speed (httpie#1516)

Open mikurei opened this issue 1 year ago • 1 comments

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

mikurei avatar Jul 14 '23 22:07 mikurei