diff --git a/packages/artifact/README.md b/packages/artifact/README.md index 8a94a911..22984913 100644 --- a/packages/artifact/README.md +++ b/packages/artifact/README.md @@ -2,7 +2,7 @@ ## Usage -You can use this package to interact with the actions artifact service to upload and download artifacts. +You can use this package to interact with the actions artifacts. - [Upload an Artifact](##Upload-an-Artifact) - [Download a Single Artifact](##Download-a-Single-Artifact) - [Download All Artifacts](##Download-all-Artifacts) @@ -67,7 +67,7 @@ const files = [ 'dir/file3.txt' ] -const rootDirectory = '.' // Also possible to specify __dirname if using node +const rootDirectory = '.' // Also possible to specify __dirname const options = { continueOnError: false } diff --git a/packages/artifact/src/internal-artifact-client.ts b/packages/artifact/src/internal-artifact-client.ts index c2d80b13..2e2433b4 100644 --- a/packages/artifact/src/internal-artifact-client.ts +++ b/packages/artifact/src/internal-artifact-client.ts @@ -217,12 +217,13 @@ export class DefaultArtifactClient implements ArtifactClient { await Promise.all( parallelDownloads.map(async () => { while (downloadedArtifacts < artifacts.count) { - const currentArtifactToUpload = artifacts.value[downloadedArtifacts] + const currentArtifactToDownload = + artifacts.value[downloadedArtifacts] downloadedArtifacts += 1 // Promise.All is not correctly inferring that 'path' is no longer possibly undefined: https://github.com/microsoft/TypeScript/issues/34925 const downloadSpecification = getDownloadSpecification( - currentArtifactToUpload.name, + currentArtifactToDownload.name, items.value, path!, // eslint-disable-line @typescript-eslint/no-non-null-assertion true @@ -233,7 +234,7 @@ export class DefaultArtifactClient implements ArtifactClient { await downloadSingleArtifact(downloadSpecification.filesToDownload) response.push({ - artifactName: currentArtifactToUpload.name, + artifactName: currentArtifactToDownload.name, downloadPath: downloadSpecification.rootDownloadLocation }) } diff --git a/packages/artifact/src/internal-download-specification.ts b/packages/artifact/src/internal-download-specification.ts index 8d6291ec..56e2003e 100644 --- a/packages/artifact/src/internal-download-specification.ts +++ b/packages/artifact/src/internal-download-specification.ts @@ -53,21 +53,16 @@ export function getDownloadSpecification( includeRootDirectory ? entry.path : entry.path.replace(artifactName, '') ) + // Case insensitive folder structure maintained in the backend, not every folder is created so the 'folder' + // itemType cannot be relied upon. The file must be used to determine the directory structure if (entry.itemType === 'file') { - // get the directories that we need to create from the filePath for each individual file + // Get the directories that we need to create from the filePath for each individual file directories.add(path.dirname(filePath)) specifications.filesToDownload.push({ sourceLocation: entry.contentLocation, targetPath: filePath }) - } else if (entry.itemType === 'folder') { - // case insensitive folder structure maintained in the backend, not every folder is created so the - // path for the file must be used to determine the directory structure - } else { - // eslint-disable-next-line no-console - console.log(entry) - throw new Error(`Unsupported item type: ${entry.itemType}`) } } }