diff --git a/packages/cache/src/cache.ts b/packages/cache/src/cache.ts index 69931e29..78439141 100644 --- a/packages/cache/src/cache.ts +++ b/packages/cache/src/cache.ts @@ -509,6 +509,10 @@ async function saveCacheV2( ) } + // 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, @@ -561,7 +565,6 @@ async function saveCacheV2( } else { core.warning(`Failed to save: ${typedError.message}`) } - throw error } finally { // Try to delete the archive to save space try { diff --git a/packages/cache/src/internal/uploadUtils.ts b/packages/cache/src/internal/uploadUtils.ts index efb80de1..7d471a0d 100644 --- a/packages/cache/src/internal/uploadUtils.ts +++ b/packages/cache/src/internal/uploadUtils.ts @@ -126,11 +126,7 @@ export async function uploadCacheArchiveSDK( ): Promise { const blobClient: BlobClient = new BlobClient(signedUploadURL) const blockBlobClient: BlockBlobClient = blobClient.getBlockBlobClient() - - const properties = await blobClient.getProperties() - const contentLength = properties.contentLength ?? -1 - - const uploadProgress = new UploadProgress(contentLength) + const uploadProgress = new UploadProgress(options?.archiveSizeBytes ?? 0) // Specify data transfer options const uploadOptions: BlockBlobParallelUploadOptions = { @@ -161,7 +157,9 @@ export async function uploadCacheArchiveSDK( return response } catch (error) { - core.debug(`Error uploading cache archive: ${error}`) + core.warning( + `uploadCacheArchiveSDK: internal error uploading cache archive: ${error.message}` + ) throw error } finally { uploadProgress.stopDisplayTimer() diff --git a/packages/cache/src/options.ts b/packages/cache/src/options.ts index 778c6a0e..08e71c10 100644 --- a/packages/cache/src/options.ts +++ b/packages/cache/src/options.ts @@ -24,6 +24,10 @@ export interface UploadOptions { * @default 32MB */ uploadChunkSize?: number + /** + * Archive size in bytes + */ + archiveSizeBytes?: number } /**