forked from kenzuya/unshackle
fix(downloader): restore requests progress for single-url downloads
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user