Run library, checks and downloads in background threads with parallel fetching

This commit is contained in:
2026-06-06 09:52:45 +02:00
parent 16d5c2857d
commit 13e4e14bac
19 changed files with 1201 additions and 618 deletions
+23 -6
View File
@@ -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