Skip to content

Commit 6cfa838

Browse files
Merge pull request #5 from WarpBuilds/hotfix-downloads
fixes download key issue
2 parents ee2d4b8 + 8783978 commit 6cfa838

File tree

4 files changed

+37
-15
lines changed

4 files changed

+37
-15
lines changed

dist/cache-save/index.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch
125125
// Internal Error
126126
return undefined;
127127
}
128+
core.debug(`Cache Entry: ${JSON.stringify(cacheEntry)}`);
128129
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
129130
core.debug(`Archive Path: ${archivePath}`);
130131
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;
132+
core.debug(`Cache Key: ${cacheKey}`);
131133
switch (cacheEntry.provider) {
132134
case 's3':
133135
case 'r2': {
@@ -142,7 +144,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch
142144
yield cacheHttpClient.downloadCache('s3', (_d = cacheEntry.s3) === null || _d === void 0 ? void 0 : _d.pre_signed_url, archivePath);
143145
}
144146
catch (error) {
145-
core.info('Cache Miss. Failed to download cache.');
147+
core.debug(`Failed to download cache: ${error}`);
148+
core.info(`Cache Miss. Failed to download cache from ${cacheEntry.provider}. Error: ${error}`);
146149
return undefined;
147150
}
148151
if (core.isDebug()) {
@@ -1451,10 +1454,17 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options
14511454
keepAlive: true
14521455
});
14531456
try {
1454-
const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.request('HEAD', archiveLocation, null, {}); }));
1455-
const lengthHeader = res.message.headers['content-length'];
1456-
if (lengthHeader === undefined || lengthHeader === null) {
1457-
throw new Error('Content-Length not found on blob response');
1457+
// Use Range request to get total file size (works with PresignGetObject URLs)
1458+
const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.get(archiveLocation, { Range: 'bytes=0-0' }); }));
1459+
const contentRange = res.message.headers['content-range'];
1460+
if (!contentRange) {
1461+
throw new Error('Content-Range header not found - server may not support range requests');
1462+
}
1463+
// Parse "bytes 0-0/12345" to get total length (12345)
1464+
const match = contentRange.match(/bytes \d+-\d+\/(\d+)/);
1465+
const lengthHeader = match === null || match === void 0 ? void 0 : match[1];
1466+
if (!lengthHeader) {
1467+
throw new Error('Could not parse total file size from Content-Range header');
14581468
}
14591469
const length = parseInt(lengthHeader);
14601470
if (Number.isNaN(length)) {
@@ -1498,6 +1508,7 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options
14981508
while (actives > 0) {
14991509
yield waitAndWrite();
15001510
}
1511+
progress.stopDisplayTimer();
15011512
}
15021513
finally {
15031514
httpClient.dispose();

dist/setup/index.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch
125125
// Internal Error
126126
return undefined;
127127
}
128+
core.debug(`Cache Entry: ${JSON.stringify(cacheEntry)}`);
128129
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
129130
core.debug(`Archive Path: ${archivePath}`);
130131
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;
132+
core.debug(`Cache Key: ${cacheKey}`);
131133
switch (cacheEntry.provider) {
132134
case 's3':
133135
case 'r2': {
@@ -142,7 +144,8 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch
142144
yield cacheHttpClient.downloadCache('s3', (_d = cacheEntry.s3) === null || _d === void 0 ? void 0 : _d.pre_signed_url, archivePath);
143145
}
144146
catch (error) {
145-
core.info('Cache Miss. Failed to download cache.');
147+
core.debug(`Failed to download cache: ${error}`);
148+
core.info(`Cache Miss. Failed to download cache from ${cacheEntry.provider}. Error: ${error}`);
146149
return undefined;
147150
}
148151
if (core.isDebug()) {
@@ -1451,10 +1454,17 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options
14511454
keepAlive: true
14521455
});
14531456
try {
1454-
const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.request('HEAD', archiveLocation, null, {}); }));
1455-
const lengthHeader = res.message.headers['content-length'];
1456-
if (lengthHeader === undefined || lengthHeader === null) {
1457-
throw new Error('Content-Length not found on blob response');
1457+
// Use Range request to get total file size (works with PresignGetObject URLs)
1458+
const res = yield (0, requestUtils_1.retryHttpClientResponse)('downloadCacheMetadata', () => __awaiter(this, void 0, void 0, function* () { return yield httpClient.get(archiveLocation, { Range: 'bytes=0-0' }); }));
1459+
const contentRange = res.message.headers['content-range'];
1460+
if (!contentRange) {
1461+
throw new Error('Content-Range header not found - server may not support range requests');
1462+
}
1463+
// Parse "bytes 0-0/12345" to get total length (12345)
1464+
const match = contentRange.match(/bytes \d+-\d+\/(\d+)/);
1465+
const lengthHeader = match === null || match === void 0 ? void 0 : match[1];
1466+
if (!lengthHeader) {
1467+
throw new Error('Could not parse total file size from Content-Range header');
14581468
}
14591469
const length = parseInt(lengthHeader);
14601470
if (Number.isNaN(length)) {
@@ -1498,6 +1508,7 @@ function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options
14981508
while (actives > 0) {
14991509
yield waitAndWrite();
15001510
}
1511+
progress.stopDisplayTimer();
15011512
}
15021513
finally {
15031514
httpClient.dispose();

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"author": "GitHub",
2626
"license": "MIT",
2727
"dependencies": {
28-
"@actions/cache": "npm:github-actions.warp-cache@1.4.6",
28+
"@actions/cache": "npm:github-actions.warp-cache@1.4.7",
2929
"@actions/core": "^1.10.0",
3030
"@actions/exec": "^1.1.0",
3131
"@actions/glob": "^0.5.0",

0 commit comments

Comments
 (0)