From 03c309303c576ddbfa5c16434b1309743da16f70 Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 6 Feb 2026 23:34:15 -0700 Subject: [PATCH] fix(downloader): restore requests progress for single-url downloads --- unshackle/core/downloaders/requests.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/unshackle/core/downloaders/requests.py b/unshackle/core/downloaders/requests.py index cb3ce5a..0cb6b4e 100644 --- a/unshackle/core/downloaders/requests.py +++ b/unshackle/core/downloaders/requests.py @@ -260,11 +260,18 @@ def requests( }, ) - yield dict(total=len(urls)) + # If we're downloading more than one URL, treat them as "segments" for progress purposes. + # For single-URL downloads we want per-chunk progress (and the inner `download()` will yield + # a chunk-based `total`), so don't set a segment total of 1 here. + segmented_batch = len(urls) > 1 + if segmented_batch: + yield dict(total=len(urls)) try: with ThreadPoolExecutor(max_workers=max_workers) as pool: - for future in as_completed(pool.submit(download, session=session, segmented=True, **url) for url in urls): + for future in as_completed( + pool.submit(download, session=session, segmented=segmented_batch, **url) for url in urls + ): try: yield from future.result() except KeyboardInterrupt: