fix(downloader): correct resume progress and avoid httpx private API
Two bugs found by code review: 1. Progress bar exceeds 100% on resumed downloads because Content-Length from a Range response covers only remaining bytes. Now adds resume_from for the true total. 2. session.transport reached into httpx.Client._transport, a private attribute that may break on httpx upgrades. Transport is now stored at construction time instead.
This commit is contained in:
1 parent
2466ef5fa8
commit
8acea390e6
4 files changed
+21
-5
No files matched your search
@@ -109,7 +109,10 @@ def _stream_to_file(
|
||||
if content_length is None:
|
||||
cl_header = resp.headers.get("content-length")
|
||||
if cl_header:
|
||||
content_length = int(cl_header)
|
||||
# Content-Length from a Range response
|
||||
# covers only remaining bytes; add
|
||||
# resume_from for true total.
|
||||
content_length = int(cl_header) + resume_from
|
||||
progress(downloaded, total=content_length)
|
||||
else:
|
||||
progress(downloaded)
|
||||
|
||||
Reference in new issue
Block a user