refactor(progress): return bound callable from start_download (#30)
start_download(book) now returns a per-book bound callable instead of raw task_id. Task identity is fully internal to progress.py — no caller ever sees or passes task_id. - Orchestrator: removed closure pattern, now threads progress_cb = start_download(book) directly - downloader: download_book() accepts optional progress= kwarg, uses it when provided (falls back to reporter.update) - cli.py: forwards progress kwarg through _download_fn - Public update() drops task_id param; bound callable calls _progress.update(task_id_internal) directly 382 tests pass (+11 new), 6/6 AC met.
This commit is contained in:
1 parent
9ac581e5b7
commit
1f46467f2c
10 files changed
+398
-95
No files matched your search
@@ -236,6 +236,8 @@ def download_book(
|
||||
session: "LibroFmSession",
|
||||
plan: "OutputPlan",
|
||||
reporter: "DownloadReporter",
|
||||
*,
|
||||
progress: "Callable[[int], None] | None" = None,
|
||||
) -> DownloadResult:
|
||||
"""Orchestrate a single book download with format strategy.
|
||||
|
||||
@@ -253,7 +255,9 @@ def download_book(
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
format_strategy = plan.format_strategy
|
||||
progress = reporter.update
|
||||
# Use provided bound callback (from start_download) or fall back to reporter.update
|
||||
if progress is None:
|
||||
progress = reporter.update
|
||||
cancel_event = reporter.cancel_event
|
||||
transport = session._client._transport
|
||||
|
||||
|
||||
Reference in new issue
Block a user