Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions dist/cache-save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -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()) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -1498,6 +1508,7 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options
while (actives > 0) {
yield waitAndWrite();
}
progress.stopDisplayTimer();
}
finally {
httpClient.dispose();
Expand Down
21 changes: 16 additions & 5 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -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()) {
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -1498,6 +1508,7 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options
while (actives > 0) {
yield waitAndWrite();
}
progress.stopDisplayTimer();
}
finally {
httpClient.dispose();
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"author": "GitHub",
"license": "MIT",
"dependencies": {
"@actions/cache": "npm:github-actions.warp-cache@1.4.6",
"@actions/cache": "npm:github-actions.warp-cache@1.4.7",
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.0",
"@actions/glob": "^0.5.0",
Expand Down
Loading