refactor: centralize progress reporters, default user-agent, improve error propagation and aria2 fetch usage

This commit is contained in:
Dariusz L
2026-07-02 02:54:38 +02:00
parent f428924ee0
commit 59e61ba077
8 changed files with 50 additions and 100 deletions
+21
View File
@@ -41,3 +41,24 @@ def report_progress(
progress_callback(payload)
except Exception as e:
log.debug(f"{error_context} failed: {e}")
def get_progress_reporter(error_context: str) -> Callable[[Optional[Callable[[Dict[str, Any]], None]], str, str, Optional[float]], None]:
"""Return a closure for reporting progress with a pre-configured error context."""
def reporter(
progress_callback: Optional[Callable[[Dict[str, Any]], None]],
stage: str,
message: str,
percent: Optional[float] = None,
**extra: Any,
) -> None:
report_progress(
progress_callback,
stage,
message,
percent,
error_context=error_context,
**extra,
)
return reporter