8000 Fix concurrent artifact downloads by Serious-senpai · Pull Request #400 · actions/download-artifact · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix concurrent artifact downloads #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118881,16 +118881,15 @@ function run() {
core.info(`- ${artifact.name} (ID: ${artifact.id}, Size: ${artifact.size}, Expected Digest: ${artifact.digest})`);
});
}
const downloadPromises = artifacts.map(artifact => ({
name: artifact.name,
promise: artifact_1.default.downloadArtifact(artifact.id, Object.assign(Object.assign({}, options), { path: isSingleArtifactDownload || inputs.mergeMultiple
? resolvedPath
: path.join(resolvedPath, artifact.name), expectedHash: artifact.digest }))
}));
const chunkedPromises = (0, exports.chunk)(downloadPromises, PARALLEL_DOWNLOADS);
for (const chunk of chunkedPromises) {
const chunkPromises = chunk.map(item => item.promise);
const results = yield Promise.all(chunkPromises);
const chunkedArtifacts = (0, exports.chunk)(artifacts, PARALLEL_DOWNLOADS);
for (const chunk of chunkedArtifacts) {
const chunkPromises = chunk.map(artifact => ({
name: artifact.name,
promise: artifact_1.default.downloadArtifact(artifact.id, Object.assign(Object.assign({}, options), { path: isSingleArtifactDownload || inputs.mergeMultiple
? resolvedPath
: path.join(resolvedPath, artifact.name), expectedHash: artifact.digest }))
}));
const results = yield Promise.all(chunkPromises.map(item => item.promise));
for (let i = 0; i < results.length; i++) {
const outcome = results[i];
const artifactName = chunk[i].name;
Expand Down
30 changes: 14 additions & 16 deletions src/download-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,20 @@ export async function run(): Promise<void> {
})
}

const downloadPromises = artifacts.map(artifact => ({
name: artifact.name,
promise: artifactClient.downloadArtifact(artifact.id, {
...options,
path:
isSingleArtifactDownload || inputs.mergeMultiple
? resolvedPath
: path.join(resolvedPath, artifact.name),
expectedHash: artifact.digest
})
}))

const chunkedPromises = chunk(downloadPromises, PARALLEL_DOWNLOADS)
for (const chunk of chunkedPromises) {
const chunkPromises = chunk.map(item => item.promise)
const results = await Promise.all(chunkPromises)
const chunkedArtifacts = chunk(artifacts, PARALLEL_DOWNLOADS)
for (const chunk of chunkedArtifacts) {
const chunkPromises = chunk.map(artifact => ({
name: artifact.name,
promise: artifactClient.downloadArtifact(artifact.id, {
...options,
path:
isSingleArtifactDownload || inputs.mergeMultiple
? resolvedPath
: path.join(resolvedPath, artifact.name),
expectedHash: artifact.digest
})
}))
const results = await Promise.all(chunkPromises.map(item => item.promise))

for (let i = 0; i < results.length; i++) {
const outcome = results[i]
Expand Down
0