Added download settings and optimized the downloader system with concurrency.
This commit is contained in:
@@ -23,6 +23,7 @@ from ptdiag.logs import (
|
||||
from . import __version__
|
||||
from .command import CommandError, CommandOutcome, CommandRunner
|
||||
from .depot import (
|
||||
DownloadOptions,
|
||||
SyncProgress,
|
||||
read_cached_depot_launch_catalog,
|
||||
select_depot_start_option,
|
||||
@@ -561,6 +562,7 @@ def _native_update(
|
||||
"""Use the native verified depot client for normal installs and updates."""
|
||||
|
||||
settings = _load_or_default_settings(paths, persist=not dry_run)
|
||||
download_options = _configured_download_options(settings)
|
||||
runner = _runner(paths, "native-update", dry_run)
|
||||
with _operation_guard(paths, "native-update", dry_run):
|
||||
_print_operation_status(as_json, 1, 3, "Checking local game files…")
|
||||
@@ -581,6 +583,11 @@ def _native_update(
|
||||
quarantine_unmanaged=verify_import,
|
||||
dry_run=dry_run,
|
||||
progress=None if as_json else _print_sync_progress,
|
||||
**(
|
||||
{"download_options": download_options}
|
||||
if download_options is not None
|
||||
else {}
|
||||
),
|
||||
)
|
||||
if verify_import and not dry_run:
|
||||
mark_game_import_verified(
|
||||
@@ -620,6 +627,7 @@ def _wine_update(
|
||||
raise LauncherError("Wine, Wineboot, and Winetricks are required; run doctor")
|
||||
runner = _runner(paths, "update", dry_run)
|
||||
settings = _load_or_default_settings(paths, persist=not dry_run)
|
||||
download_options = _configured_download_options(settings)
|
||||
with _operation_guard(paths, "update", dry_run):
|
||||
configure_launcher_prefix(
|
||||
paths,
|
||||
@@ -647,6 +655,11 @@ def _wine_update(
|
||||
repair=True,
|
||||
quarantine_unmanaged=True,
|
||||
progress=None if as_json else _print_sync_progress,
|
||||
**(
|
||||
{"download_options": download_options}
|
||||
if download_options is not None
|
||||
else {}
|
||||
),
|
||||
)
|
||||
mark_game_import_verified(
|
||||
paths,
|
||||
@@ -677,6 +690,20 @@ def _print_sync_progress(progress: SyncProgress) -> None:
|
||||
print(f"PROGRESS {json.dumps(asdict(progress), sort_keys=True)}", flush=True)
|
||||
|
||||
|
||||
def _configured_download_options(settings: Settings) -> DownloadOptions | None:
|
||||
if (
|
||||
settings.download_speed_limit_bytes_per_second is None
|
||||
and not settings.low_bandwidth_mode
|
||||
):
|
||||
return None
|
||||
return DownloadOptions(
|
||||
bandwidth_limit_bytes_per_second=(
|
||||
settings.download_speed_limit_bytes_per_second
|
||||
),
|
||||
low_bandwidth=settings.low_bandwidth_mode,
|
||||
)
|
||||
|
||||
|
||||
def _print_operation_status(
|
||||
as_json: bool,
|
||||
step: int,
|
||||
|
||||
Reference in New Issue
Block a user