From bf8b778ecca59866776ba03bcf5c10e36db0f0ee Mon Sep 17 00:00:00 2001 From: Prajjwal Date: Thu, 24 Jul 2025 18:30:43 +0530 Subject: [PATCH] updates package --- dist/restore/index.js | 21 ++++++++++++++++----- dist/save/index.js | 21 ++++++++++++++++----- package-lock.json | 8 ++++---- package.json | 2 +- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index 27805190..8c20d849 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -125,9 +125,11 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch // Internal Error return undefined; } + core.debug(`Cache Entry: ${JSON.stringify(cacheEntry)}`); archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); core.debug(`Archive Path: ${archivePath}`); const cacheKey = (_b = (_a = cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cache_entry) === null || _a === void 0 ? void 0 : _a.cache_user_given_key) !== null && _b !== void 0 ? _b : primaryKey; + core.debug(`Cache Key: ${cacheKey}`); switch (cacheEntry.provider) { case 's3': case 'r2': { @@ -142,7 +144,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch yield cacheHttpClient.downloadCache('s3', (_d = cacheEntry.s3) === null || _d === void 0 ? void 0 : _d.pre_signed_url, archivePath); } catch (error) { - core.info('Cache Miss. Failed to download cache.'); + core.debug(`Failed to download cache: ${error}`); + core.info(`Cache Miss. Failed to download cache from ${cacheEntry.provider}. Error: ${error}`); return undefined; } if (core.isDebug()) { @@ -1451,10 +1454,17 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options keepAlive: true }); try { - const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.request('HEAD', archiveLocation, null, {}); })); - const lengthHeader = res.message.headers['content-length']; - if (lengthHeader === undefined || lengthHeader === null) { - throw new Error('Content-Length not found on blob response'); + // Use Range request to get total file size (works with PresignGetObject URLs) + const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.get(archiveLocation, { Range: 'bytes=0-0' }); })); + const contentRange = res.message.headers['content-range']; + if (!contentRange) { + throw new Error('Content-Range header not found - server may not support range requests'); + } + // Parse "bytes 0-0/12345" to get total length (12345) + const match = contentRange.match(/bytes \d+-\d+\/(\d+)/); + const lengthHeader = match === null || match === void 0 ? void 0 : match[1]; + if (!lengthHeader) { + throw new Error('Could not parse total file size from Content-Range header'); } const length = parseInt(lengthHeader); if (Number.isNaN(length)) { @@ -1498,6 +1508,7 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options while (actives > 0) { yield waitAndWrite(); } + progress.stopDisplayTimer(); } finally { httpClient.dispose(); diff --git a/dist/save/index.js b/dist/save/index.js index a6f5536c..aada92ed 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -125,9 +125,11 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch // Internal Error return undefined; } + core.debug(`Cache Entry: ${JSON.stringify(cacheEntry)}`); archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); core.debug(`Archive Path: ${archivePath}`); const cacheKey = (_b = (_a = cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cache_entry) === null || _a === void 0 ? void 0 : _a.cache_user_given_key) !== null && _b !== void 0 ? _b : primaryKey; + core.debug(`Cache Key: ${cacheKey}`); switch (cacheEntry.provider) { case 's3': case 'r2': { @@ -142,7 +144,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch yield cacheHttpClient.downloadCache('s3', (_d = cacheEntry.s3) === null || _d === void 0 ? void 0 : _d.pre_signed_url, archivePath); } catch (error) { - core.info('Cache Miss. Failed to download cache.'); + core.debug(`Failed to download cache: ${error}`); + core.info(`Cache Miss. Failed to download cache from ${cacheEntry.provider}. Error: ${error}`); return undefined; } if (core.isDebug()) { @@ -1451,10 +1454,17 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options keepAlive: true }); try { - const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.request('HEAD', archiveLocation, null, {}); })); - const lengthHeader = res.message.headers['content-length']; - if (lengthHeader === undefined || lengthHeader === null) { - throw new Error('Content-Length not found on blob response'); + // Use Range request to get total file size (works with PresignGetObject URLs) + const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.get(archiveLocation, { Range: 'bytes=0-0' }); })); + const contentRange = res.message.headers['content-range']; + if (!contentRange) { + throw new Error('Content-Range header not found - server may not support range requests'); + } + // Parse "bytes 0-0/12345" to get total length (12345) + const match = contentRange.match(/bytes \d+-\d+\/(\d+)/); + const lengthHeader = match === null || match === void 0 ? void 0 : match[1]; + if (!lengthHeader) { + throw new Error('Could not parse total file size from Content-Range header'); } const length = parseInt(lengthHeader); if (Number.isNaN(length)) { @@ -1498,6 +1508,7 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options while (actives > 0) { yield waitAndWrite(); } + progress.stopDisplayTimer(); } finally { httpClient.dispose(); diff --git a/package-lock.json b/package-lock.json index 7fb8a650..a42f7760 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "LGPL-3.0", "dependencies": { "@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.2.0", - "@actions/cache": "npm:github-actions.warp-cache@1.4.6", + "@actions/cache": "npm:github-actions.warp-cache@1.4.7", "@actions/core": "^1.10.1", "@actions/exec": "^1.1.1", "@actions/glob": "^0.4.0", @@ -52,9 +52,9 @@ }, "node_modules/@actions/cache": { "name": "github-actions.warp-cache", - "version": "1.4.6", - "resolved": "https://registry.npmjs.org/github-actions.warp-cache/-/github-actions.warp-cache-1.4.6.tgz", - "integrity": "sha512-WAB/kEi4Knb0PxS0xSWGPKJ0UNU31LzK9vpt6IYpPdk32bXicq/ncxLwN/28zssxNF+f+T1Ch79/nZcjFGUi7g==", + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/github-actions.warp-cache/-/github-actions.warp-cache-1.4.7.tgz", + "integrity": "sha512-TwYF+iv/l1uZRp3D0iBj+zoPZPhd3gpvKuarLxnB9de7KUFvG79M3fDIqhjjXa4l53XcfZKBt31H6UcsKiXlTw==", "license": "MIT", "dependencies": { "@actions/core": "^1.10.0", diff --git a/package.json b/package.json index 0afe610f..0e271a71 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "homepage": "https://github.com/Swatinem/rust-cache#readme", "dependencies": { "@actions/buildjet-cache": "npm:github-actions.cache-buildjet@0.2.0", - "@actions/cache": "npm:github-actions.warp-cache@1.4.6", + "@actions/cache": "npm:github-actions.warp-cache@1.4.7", "@actions/core": "^1.10.1", "@actions/exec": "^1.1.1", "@actions/glob": "^0.4.0",