dfdf
This commit is contained in:
14
API/HTTP.py
14
API/HTTP.py
@@ -229,6 +229,13 @@ class HTTPClient:
|
||||
response.raise_for_status()
|
||||
total_bytes = int(response.headers.get("content-length", 0))
|
||||
bytes_downloaded = 0
|
||||
|
||||
# Render progress immediately (even if the transfer is very fast)
|
||||
if progress_callback:
|
||||
try:
|
||||
progress_callback(0, total_bytes)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
with open(path, "wb") as f:
|
||||
for chunk in response.iter_bytes(chunk_size):
|
||||
@@ -237,6 +244,13 @@ class HTTPClient:
|
||||
bytes_downloaded += len(chunk)
|
||||
if progress_callback:
|
||||
progress_callback(bytes_downloaded, total_bytes)
|
||||
|
||||
# Ensure a final callback is emitted.
|
||||
if progress_callback:
|
||||
try:
|
||||
progress_callback(bytes_downloaded, total_bytes)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user