Run library, checks and downloads in background threads with parallel fetching
This commit is contained in:
+23
-6
@@ -99,9 +99,18 @@ class InstallerDownloader:
|
||||
callback.on_finished(False, f"HTTP {response.status_code}")
|
||||
return False
|
||||
|
||||
total_size = int(response.headers.get("content-length", 0)) + existing_size
|
||||
downloaded = existing_size
|
||||
mode = "ab" if existing_size > 0 else "wb"
|
||||
# Only append if the server honored the Range request (206). A plain 200
|
||||
# means the body starts from byte 0, so appending would corrupt the file.
|
||||
if existing_size > 0 and response.status_code == 206:
|
||||
downloaded = existing_size
|
||||
mode = "ab"
|
||||
total_size = int(response.headers.get("content-length", 0)) + existing_size
|
||||
else:
|
||||
if existing_size > 0:
|
||||
logger.warning(f"Server ignored Range for {real_filename}, restarting download")
|
||||
downloaded = 0
|
||||
mode = "wb"
|
||||
total_size = int(response.headers.get("content-length", 0))
|
||||
|
||||
last_time = time.monotonic()
|
||||
last_downloaded = downloaded
|
||||
@@ -194,9 +203,17 @@ class InstallerDownloader:
|
||||
callback.on_finished(False, f"HTTP {response.status_code}")
|
||||
return False
|
||||
|
||||
total_size = int(response.headers.get("content-length", 0)) + existing_size
|
||||
downloaded = existing_size
|
||||
mode = "ab" if existing_size > 0 else "wb"
|
||||
# Only append if the server honored the Range request (206).
|
||||
if existing_size > 0 and response.status_code == 206:
|
||||
downloaded = existing_size
|
||||
mode = "ab"
|
||||
total_size = int(response.headers.get("content-length", 0)) + existing_size
|
||||
else:
|
||||
if existing_size > 0:
|
||||
logger.warning(f"Server ignored Range for {real_filename}, restarting download")
|
||||
downloaded = 0
|
||||
mode = "wb"
|
||||
total_size = int(response.headers.get("content-length", 0))
|
||||
|
||||
last_time = time.monotonic()
|
||||
last_downloaded = downloaded
|
||||
|
||||
Reference in New Issue
Block a user