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:
1 parent
83254750e6
commit
75a6eb61ea
7 files changed
+301
-25
No files matched your search
@@ -90,9 +90,17 @@ def _download_one(
|
||||
- error: exception string if download_fn raised, else None
|
||||
- was_skipped: True if download_fn returned None (skipped)
|
||||
"""
|
||||
reporter.start_download(book)
|
||||
task_id = reporter.start_download(book)
|
||||
|
||||
# Create a per-book progress callback bound to this book's task_id.
|
||||
# Without this, reporter.update() falls back to the most-recently-started
|
||||
# bar (see ProgressReporter.update), so all parallel downloads would
|
||||
# update the same progress bar.
|
||||
def _progress(completed: int, *, total: int | None = None) -> None:
|
||||
reporter.update(completed, total=total, task_id=task_id)
|
||||
|
||||
try:
|
||||
result = download_fn(book)
|
||||
result = download_fn(book, progress=_progress)
|
||||
if result is None:
|
||||
# Skipped (no format available)
|
||||
reporter.complete(book) # still "complete" the progress tracking
|
||||
|
||||
Reference in new issue
Block a user