From 14f28534ef4696c22c75a01d2246c42e46a85d47 Mon Sep 17 00:00:00 2001 From: Sampark Sharma Date: Fri, 10 Feb 2023 12:02:26 +0000 Subject: [PATCH] Stop progress bar on message.complete --- packages/cache/src/internal/downloadUtils.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/cache/src/internal/downloadUtils.ts b/packages/cache/src/internal/downloadUtils.ts index 1f3d5b78..96775bdc 100644 --- a/packages/cache/src/internal/downloadUtils.ts +++ b/packages/cache/src/internal/downloadUtils.ts @@ -161,8 +161,9 @@ export class DownloadProgress { } } -async function displayDownloadProgress(socket: any, startTime: number): Promise { - while(!socket.destroyed) { +async function displayDownloadProgress(message: any, startTime: number): Promise { + const socket = message.socket + while(!message.complete) { const byteRead = socket.bytesRead const totalBytes = 100000 const percentage = (100 * (byteRead / totalBytes)).toFixed( @@ -178,7 +179,7 @@ async function displayDownloadProgress(socket: any, startTime: number): Promise< core.info( `Received ${byteRead} of ${totalBytes} (${percentage}%), ${downloadSpeed} MBs/sec` ) - sleep(10) + sleep(100) } } @@ -206,7 +207,7 @@ export async function downloadCacheHttpClient( core.debug(`Aborting download, socket timed out after ${SocketTimeout} ms`) }) - await displayDownloadProgress(downloadResponse.message.socket, startTime) + await displayDownloadProgress(downloadResponse.message, startTime) await pipeResponseToStream(downloadResponse, writeStream)