fix(progress): wire task_id through parallel progress callback

In parallel download mode, all progress updates went to the same
(most recently started) bar because task_id was never threaded from
start_download() to the update callback. Create per-book closure in
orchestrator that binds task_id, pass through cli._download_fn as
optional kwarg. 3 new regression tests. 259 total.
This commit is contained in:
AlexKucera committed 2026-06-04 13:26:38 +02:00
1 parent 83254750e6
commit 75a6eb61ea
7 files changed
+301 -25

No files matched your search

+6 -2
View File
@@ -148,7 +148,11 @@ def run(
def _make_download_fn():
"""Closure capturing client, config, history, reporter for each book."""
def _download_fn(book: Book):
def _download_fn(book: Book, *, progress: "Callable[[int], None] | None" = None):
# Allow orchestrator to inject a per-book bound progress callback.
# Falls back to the shared reporter.update when not in parallel mode.
if progress is None:
progress = reporter.update
return download_book(
book=book,
client=client,
@@ -156,7 +160,7 @@ def run(
history=history,
format_strategy=config.format,
config=config,
progress=reporter.update,
progress=progress,
cancel_event=cancel_event,
)
return _download_fn