From 1b2fea8bc3f3b63c4a6278e4fa67dc7253279706 Mon Sep 17 00:00:00 2001 From: Bassem Dghaidi <568794+Link-@users.noreply.github.com> Date: Mon, 2 Dec 2024 03:56:52 -0800 Subject: [PATCH] Fix upload progress bug --- dist/restore-only/index.js | 11 ++++++----- dist/restore/index.js | 11 ++++++----- dist/save-only/index.js | 11 ++++++----- dist/save/index.js | 11 ++++++----- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index 1be9691..965b966 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -6255,6 +6255,9 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { if (archiveFileSize > constants_1.CacheFileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } + // Set the archive size in the options, will be used to display the upload + // progress + options.archiveSizeBytes = archiveFileSize; core.debug('Reserving Cache'); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request = { @@ -6288,7 +6291,6 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { core.info(`Failed to save: ${typedError.message}`); } else { - core.warning(`Failed to save: ${typedError.stack}`); core.warning(`Failed to save: ${typedError.message}`); } } @@ -9825,12 +9827,11 @@ class UploadProgress { } exports.UploadProgress = UploadProgress; function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) { + var _a; return __awaiter(this, void 0, void 0, function* () { const blobClient = new storage_blob_1.BlobClient(signedUploadURL); const blockBlobClient = blobClient.getBlockBlobClient(); - // const properties = await blobClient.getProperties() - // const contentLength = properties.contentLength ?? -1 - const uploadProgress = new UploadProgress(100 * 1024 * 1024); + const uploadProgress = new UploadProgress((_a = options === null || options === void 0 ? void 0 : options.archiveSizeBytes) !== null && _a !== void 0 ? _a : 0); // Specify data transfer options const uploadOptions = { blockSize: options === null || options === void 0 ? void 0 : options.uploadChunkSize, @@ -9849,7 +9850,7 @@ function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) { return response; } catch (error) { - core.debug(`Error uploading cache archive: ${error}`); + core.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error.message}`); throw error; } finally { diff --git a/dist/restore/index.js b/dist/restore/index.js index bb9d575..1826aa1 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -6255,6 +6255,9 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { if (archiveFileSize > constants_1.CacheFileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } + // Set the archive size in the options, will be used to display the upload + // progress + options.archiveSizeBytes = archiveFileSize; core.debug('Reserving Cache'); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request = { @@ -6288,7 +6291,6 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { core.info(`Failed to save: ${typedError.message}`); } else { - core.warning(`Failed to save: ${typedError.stack}`); core.warning(`Failed to save: ${typedError.message}`); } } @@ -9825,12 +9827,11 @@ class UploadProgress { } exports.UploadProgress = UploadProgress; function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) { + var _a; return __awaiter(this, void 0, void 0, function* () { const blobClient = new storage_blob_1.BlobClient(signedUploadURL); const blockBlobClient = blobClient.getBlockBlobClient(); - // const properties = await blobClient.getProperties() - // const contentLength = properties.contentLength ?? -1 - const uploadProgress = new UploadProgress(100 * 1024 * 1024); + const uploadProgress = new UploadProgress((_a = options === null || options === void 0 ? void 0 : options.archiveSizeBytes) !== null && _a !== void 0 ? _a : 0); // Specify data transfer options const uploadOptions = { blockSize: options === null || options === void 0 ? void 0 : options.uploadChunkSize, @@ -9849,7 +9850,7 @@ function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) { return response; } catch (error) { - core.debug(`Error uploading cache archive: ${error}`); + core.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error.message}`); throw error; } finally { diff --git a/dist/save-only/index.js b/dist/save-only/index.js index d7ab75b..5addce2 100644 --- a/dist/save-only/index.js +++ b/dist/save-only/index.js @@ -6255,6 +6255,9 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { if (archiveFileSize > constants_1.CacheFileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } + // Set the archive size in the options, will be used to display the upload + // progress + options.archiveSizeBytes = archiveFileSize; core.debug('Reserving Cache'); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request = { @@ -6288,7 +6291,6 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { core.info(`Failed to save: ${typedError.message}`); } else { - core.warning(`Failed to save: ${typedError.stack}`); core.warning(`Failed to save: ${typedError.message}`); } } @@ -9825,12 +9827,11 @@ class UploadProgress { } exports.UploadProgress = UploadProgress; function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) { + var _a; return __awaiter(this, void 0, void 0, function* () { const blobClient = new storage_blob_1.BlobClient(signedUploadURL); const blockBlobClient = blobClient.getBlockBlobClient(); - // const properties = await blobClient.getProperties() - // const contentLength = properties.contentLength ?? -1 - const uploadProgress = new UploadProgress(100 * 1024 * 1024); + const uploadProgress = new UploadProgress((_a = options === null || options === void 0 ? void 0 : options.archiveSizeBytes) !== null && _a !== void 0 ? _a : 0); // Specify data transfer options const uploadOptions = { blockSize: options === null || options === void 0 ? void 0 : options.uploadChunkSize, @@ -9849,7 +9850,7 @@ function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) { return response; } catch (error) { - core.debug(`Error uploading cache archive: ${error}`); + core.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error.message}`); throw error; } finally { diff --git a/dist/save/index.js b/dist/save/index.js index 85b54ad..f1e9f9c 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -6255,6 +6255,9 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { if (archiveFileSize > constants_1.CacheFileSizeLimit && !(0, config_1.isGhes)()) { throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`); } + // Set the archive size in the options, will be used to display the upload + // progress + options.archiveSizeBytes = archiveFileSize; core.debug('Reserving Cache'); const version = utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive); const request = { @@ -6288,7 +6291,6 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) { core.info(`Failed to save: ${typedError.message}`); } else { - core.warning(`Failed to save: ${typedError.stack}`); core.warning(`Failed to save: ${typedError.message}`); } } @@ -9825,12 +9827,11 @@ class UploadProgress { } exports.UploadProgress = UploadProgress; function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) { + var _a; return __awaiter(this, void 0, void 0, function* () { const blobClient = new storage_blob_1.BlobClient(signedUploadURL); const blockBlobClient = blobClient.getBlockBlobClient(); - // const properties = await blobClient.getProperties() - // const contentLength = properties.contentLength ?? -1 - const uploadProgress = new UploadProgress(100 * 1024 * 1024); + const uploadProgress = new UploadProgress((_a = options === null || options === void 0 ? void 0 : options.archiveSizeBytes) !== null && _a !== void 0 ? _a : 0); // Specify data transfer options const uploadOptions = { blockSize: options === null || options === void 0 ? void 0 : options.uploadChunkSize, @@ -9849,7 +9850,7 @@ function uploadCacheArchiveSDK(signedUploadURL, archivePath, options) { return response; } catch (error) { - core.debug(`Error uploading cache archive: ${error}`); + core.warning(`uploadCacheArchiveSDK: internal error uploading cache archive: ${error.message}`); throw error; } finally {