From fe0c0de7dbd55a505798bf3523557bba42e47325 Mon Sep 17 00:00:00 2001 From: Vallie Joseph Date: Thu, 28 Mar 2024 17:53:08 +0000 Subject: [PATCH] adding lock --- packages/artifact/src/internal/upload/zip.ts | 42 ++++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/packages/artifact/src/internal/upload/zip.ts b/packages/artifact/src/internal/upload/zip.ts index d022822a..3c5b1ed2 100644 --- a/packages/artifact/src/internal/upload/zip.ts +++ b/packages/artifact/src/internal/upload/zip.ts @@ -39,41 +39,39 @@ export async function createZipUploadStream( zip.on('finish', zipFinishCallback) zip.on('end', zipEndCallback) - const uploadFilePromises = uploadSpecification.map(async file => { - return new Promise((resolve, reject) => { + for (const file of uploadSpecification) { + await new Promise((resolve, reject) => { if (file.sourcePath !== null) { + // Add a normal file to the zip zip.entry( createReadStream(file.sourcePath), {name: file.destinationPath}, - (err, entry) => { + function (err, entry) { + core.debug(`Entry is: ${entry}`) if (err) reject(err) - resolve(entry) + else resolve(entry) } ) } else { - zip.entry(null, {name: file.destinationPath}, (err, entry) => { + zip.entry(null, {name: file.destinationPath}, function (err, entry) { + core.debug(`Entry is: ${entry}`) if (err) reject(err) - resolve(entry) + else resolve(entry) }) } }) - }) + } - await Promise.all(uploadFilePromises).then(result => { - core.debug(`Zip result is ${result}`) - zip.finalize() - const bufferSize = getUploadChunkSize() - const zipUploadStream = new ZipUploadStream(bufferSize) - core.debug( - `Zip write high watermark value ${zipUploadStream.writableHighWaterMark}` - ) - core.debug( - `Zip read high watermark value ${zipUploadStream.readableHighWaterMark}` - ) - return zipUploadStream - }) - throw new Error('An error has occurred during zip creation for the artifact') - // zip.pipe(zipUploadStream) + zip.finalize() + const bufferSize = getUploadChunkSize() + const zipUploadStream = new ZipUploadStream(bufferSize) + core.debug( + `Zip write high watermark value ${zipUploadStream.writableHighWaterMark}` + ) + core.debug( + `Zip read high watermark value ${zipUploadStream.readableHighWaterMark}` + ) + return zipUploadStream } // eslint-disable-next-line @typescript-eslint/no-explicit-any