From da9cc2c0d93ea87e4819bb1dd3d3ffce9eb857d7 Mon Sep 17 00:00:00 2001 From: Michal Dorner Date: Mon, 15 Feb 2021 20:29:51 +0100 Subject: [PATCH] Show artifact download progress --- src/input-providers/artifact-provider.ts | 2 +- src/utils/github-utils.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/input-providers/artifact-provider.ts b/src/input-providers/artifact-provider.ts index 661546b..96e32c8 100644 --- a/src/input-providers/artifact-provider.ts +++ b/src/input-providers/artifact-provider.ts @@ -67,7 +67,7 @@ export class ArtifactProvider implements InputProvider { } for (const art of artifacts) { - await downloadArtifact(this.octokit, art.id, art.name, this.token) + await downloadArtifact(this.octokit, art.id, art.name, art.size_in_bytes, this.token) const reportName = this.getReportName(art.name) const files: FileContent[] = [] const zip = new Zip(art.name) diff --git a/src/utils/github-utils.ts b/src/utils/github-utils.ts index db4d3e9..b795a94 100644 --- a/src/utils/github-utils.ts +++ b/src/utils/github-utils.ts @@ -33,6 +33,7 @@ export async function downloadArtifact( octokit: InstanceType, artifactId: number, fileName: string, + size: number, token: string ): Promise { core.startGroup(`Downloading artifact ${fileName}`) @@ -72,9 +73,9 @@ export async function downloadArtifact( const fileWriterStream = createWriteStream(fileName) core.info(`Downloading ${url}`) - downloadStream.on('downloadProgress', ({transferred, total, percent}) => { - const percentage = Math.round(percent * 100) - core.info(`Progress: ${transferred}/${total} (${percentage}%)`) + downloadStream.on('downloadProgress', ({transferred}) => { + const percentage = Math.round(transferred / size * 100) + core.info(`Progress: ${transferred}/${size} (${percentage}%)`) }) await asyncStream(downloadStream, fileWriterStream) } finally {