feat(images): parallelize image downloads #345
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #322
Applied changes based on Issue #322.
I’ve updated
downloadImages
to fetch in parallel with a fixed concurrency of 5, preserving the original URL order and still logging per-image successes or failures.Summary of changes:
• Introduce a
concurrency = 5
constant and split the URL list into batches.• Within each batch, kick off all downloads via
Promise.all
, rather than awaiting each one in sequence.• Collect results into a fixed-length array so that download paths stay in the same order as the input URLs.
• Filter out any failed downloads before returning the final array of relative paths.
With this change, you’ll get up to 5 simultaneous downloads, greatly reducing total download time on large image sets without adding any new dependencies. Let me know if you’d like the concurrency to be configurable or have any other tweaks in mind!