@actions/cache
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -213,6 +213,4 @@ "use strict"; | ||
downloadProgress.startDisplayTimer(); | ||
const abortSignal = abort_controller_1.AbortController.timeout(options.segmentTimeoutInMs || 3600000); | ||
abortSignal.addEventListener('abort', () => { | ||
core.warning('Aborting cache download as it exceeded the timeout.'); | ||
}); | ||
const controller = new abort_controller_1.AbortController(); | ||
const abortSignal = controller.signal; | ||
while (!downloadProgress.isDone()) { | ||
@@ -222,8 +220,14 @@ const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize; | ||
downloadProgress.nextSegment(segmentSize); | ||
const result = yield client.downloadToBuffer(segmentStart, segmentSize, { | ||
const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, { | ||
abortSignal, | ||
concurrency: options.downloadConcurrency, | ||
onProgress: downloadProgress.onProgress() | ||
}); | ||
fs.writeFileSync(fd, result); | ||
})); | ||
if (result === 'timeout') { | ||
controller.abort(); | ||
throw new Error('Aborting cache download as the download time exceeded the timeout.'); | ||
} | ||
else if (Buffer.isBuffer(result)) { | ||
fs.writeFileSync(fd, result); | ||
} | ||
} | ||
@@ -239,2 +243,12 @@ } | ||
exports.downloadCacheStorageSDK = downloadCacheStorageSDK; | ||
const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () { | ||
let timeoutHandle; | ||
const timeoutPromise = new Promise(resolve => { | ||
timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs); | ||
}); | ||
return Promise.race([promise, timeoutPromise]).then(result => { | ||
clearTimeout(timeoutHandle); | ||
return result; | ||
}); | ||
}); | ||
//# sourceMappingURL=downloadUtils.js.map |
{ | ||
"name": "@actions/cache", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"preview": true, | ||
@@ -5,0 +5,0 @@ "description": "Actions cache lib", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97915
1437