Skip to content

Commit e839c25

Browse files
committed
Updated actions/cache version to 3.0.3
1 parent 33a923d commit e839c25

4 files changed

Lines changed: 50 additions & 22 deletions

File tree

dist/restore/index.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5657,20 +5657,24 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
56575657
const fd = fs.openSync(archivePath, 'w');
56585658
try {
56595659
downloadProgress.startDisplayTimer();
5660-
const abortSignal = abort_controller_1.AbortController.timeout(options.segmentTimeoutInMs || 3600000);
5661-
abortSignal.addEventListener('abort', () => {
5662-
core.warning('Aborting cache download as it exceeded the timeout.');
5663-
});
5660+
const controller = new abort_controller_1.AbortController();
5661+
const abortSignal = controller.signal;
56645662
while (!downloadProgress.isDone()) {
56655663
const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize;
56665664
const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart);
56675665
downloadProgress.nextSegment(segmentSize);
5668-
const result = yield client.downloadToBuffer(segmentStart, segmentSize, {
5666+
const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, {
56695667
abortSignal,
56705668
concurrency: options.downloadConcurrency,
56715669
onProgress: downloadProgress.onProgress()
5672-
});
5673-
fs.writeFileSync(fd, result);
5670+
}));
5671+
if (result === 'timeout') {
5672+
controller.abort();
5673+
throw new Error('Aborting cache download as the download time exceeded the timeout.');
5674+
}
5675+
else if (Buffer.isBuffer(result)) {
5676+
fs.writeFileSync(fd, result);
5677+
}
56745678
}
56755679
}
56765680
finally {
@@ -5681,6 +5685,16 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
56815685
});
56825686
}
56835687
exports.downloadCacheStorageSDK = downloadCacheStorageSDK;
5688+
const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () {
5689+
let timeoutHandle;
5690+
const timeoutPromise = new Promise(resolve => {
5691+
timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs);
5692+
});
5693+
return Promise.race([promise, timeoutPromise]).then(result => {
5694+
clearTimeout(timeoutHandle);
5695+
return result;
5696+
});
5697+
});
56845698
//# sourceMappingURL=downloadUtils.js.map
56855699

56865700
/***/ }),

dist/save/index.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5657,20 +5657,24 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
56575657
const fd = fs.openSync(archivePath, 'w');
56585658
try {
56595659
downloadProgress.startDisplayTimer();
5660-
const abortSignal = abort_controller_1.AbortController.timeout(options.segmentTimeoutInMs || 3600000);
5661-
abortSignal.addEventListener('abort', () => {
5662-
core.warning('Aborting cache download as it exceeded the timeout.');
5663-
});
5660+
const controller = new abort_controller_1.AbortController();
5661+
const abortSignal = controller.signal;
56645662
while (!downloadProgress.isDone()) {
56655663
const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize;
56665664
const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart);
56675665
downloadProgress.nextSegment(segmentSize);
5668-
const result = yield client.downloadToBuffer(segmentStart, segmentSize, {
5666+
const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, {
56695667
abortSignal,
56705668
concurrency: options.downloadConcurrency,
56715669
onProgress: downloadProgress.onProgress()
5672-
});
5673-
fs.writeFileSync(fd, result);
5670+
}));
5671+
if (result === 'timeout') {
5672+
controller.abort();
5673+
throw new Error('Aborting cache download as the download time exceeded the timeout.');
5674+
}
5675+
else if (Buffer.isBuffer(result)) {
5676+
fs.writeFileSync(fd, result);
5677+
}
56745678
}
56755679
}
56765680
finally {
@@ -5681,6 +5685,16 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
56815685
});
56825686
}
56835687
exports.downloadCacheStorageSDK = downloadCacheStorageSDK;
5688+
const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () {
5689+
let timeoutHandle;
5690+
const timeoutPromise = new Promise(resolve => {
5691+
timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs);
5692+
});
5693+
return Promise.race([promise, timeoutPromise]).then(result => {
5694+
clearTimeout(timeoutHandle);
5695+
return result;
5696+
});
5697+
});
56845698
//# sourceMappingURL=downloadUtils.js.map
56855699

56865700
/***/ }),

package-lock.json

Lines changed: 7 additions & 7 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
@@ -23,7 +23,7 @@
2323
"author": "GitHub",
2424
"license": "MIT",
2525
"dependencies": {
26-
"@actions/cache": "^3.0.2",
26+
"@actions/cache": "^3.0.3",
2727
"@actions/core": "^1.7.0",
2828
"@actions/exec": "^1.1.1",
2929
"@actions/io": "^1.1.2"

0 commit comments

Comments
 (0)