Skip to content

Commit 032fa5c

Browse files
build(deps): bump @actions/cache from 3.0.0 to 3.0.3 (#549)
1 parent b7bf60a commit 032fa5c

File tree

4 files changed

+92
-30
lines changed

4 files changed

+92
-30
lines changed

dist/post_run/index.js

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,13 @@ function resolvePaths(patterns) {
525525
.replace(new RegExp(`\\${path.sep}`, 'g'), '/');
526526
core.debug(`Matched: ${relativeFile}`);
527527
// Paths are made relative so the tar entries are all relative to the root of the workspace.
528-
paths.push(`${relativeFile}`);
528+
if (relativeFile === '') {
529+
// path.relative returns empty string if workspace and file are equal
530+
paths.push('.');
531+
}
532+
else {
533+
paths.push(`${relativeFile}`);
534+
}
529535
}
530536
}
531537
catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -683,6 +689,7 @@ const util = __importStar(__nccwpck_require__(3837));
683689
const utils = __importStar(__nccwpck_require__(1518));
684690
const constants_1 = __nccwpck_require__(8840);
685691
const requestUtils_1 = __nccwpck_require__(3981);
692+
const abort_controller_1 = __nccwpck_require__(2557);
686693
/**
687694
* Pipes the body of a HTTP response to a stream
688695
*
@@ -866,15 +873,24 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
866873
const fd = fs.openSync(archivePath, 'w');
867874
try {
868875
downloadProgress.startDisplayTimer();
876+
const controller = new abort_controller_1.AbortController();
877+
const abortSignal = controller.signal;
869878
while (!downloadProgress.isDone()) {
870879
const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize;
871880
const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart);
872881
downloadProgress.nextSegment(segmentSize);
873-
const result = yield client.downloadToBuffer(segmentStart, segmentSize, {
882+
const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, {
883+
abortSignal,
874884
concurrency: options.downloadConcurrency,
875885
onProgress: downloadProgress.onProgress()
876-
});
877-
fs.writeFileSync(fd, result);
886+
}));
887+
if (result === 'timeout') {
888+
controller.abort();
889+
throw new Error('Aborting cache download as the download time exceeded the timeout.');
890+
}
891+
else if (Buffer.isBuffer(result)) {
892+
fs.writeFileSync(fd, result);
893+
}
878894
}
879895
}
880896
finally {
@@ -885,6 +901,16 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
885901
});
886902
}
887903
exports.downloadCacheStorageSDK = downloadCacheStorageSDK;
904+
const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () {
905+
let timeoutHandle;
906+
const timeoutPromise = new Promise(resolve => {
907+
timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs);
908+
});
909+
return Promise.race([promise, timeoutPromise]).then(result => {
910+
clearTimeout(timeoutHandle);
911+
return result;
912+
});
913+
});
888914
//# sourceMappingURL=downloadUtils.js.map
889915

890916
/***/ }),
@@ -1102,9 +1128,9 @@ function extractTar(archivePath, compressionMethod) {
11021128
function getCompressionProgram() {
11031129
switch (compressionMethod) {
11041130
case constants_1.CompressionMethod.Zstd:
1105-
return ['--use-compress-program', 'zstd -d --long=30'];
1131+
return ['--use-compress-program', 'unzstd --long=30'];
11061132
case constants_1.CompressionMethod.ZstdWithoutLong:
1107-
return ['--use-compress-program', 'zstd -d'];
1133+
return ['--use-compress-program', 'unzstd'];
11081134
default:
11091135
return ['-z'];
11101136
}
@@ -1135,9 +1161,9 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) {
11351161
function getCompressionProgram() {
11361162
switch (compressionMethod) {
11371163
case constants_1.CompressionMethod.Zstd:
1138-
return ['--use-compress-program', 'zstd -T0 --long=30'];
1164+
return ['--use-compress-program', 'zstdmt --long=30'];
11391165
case constants_1.CompressionMethod.ZstdWithoutLong:
1140-
return ['--use-compress-program', 'zstd -T0'];
1166+
return ['--use-compress-program', 'zstdmt'];
11411167
default:
11421168
return ['-z'];
11431169
}
@@ -1168,9 +1194,9 @@ function listTar(archivePath, compressionMethod) {
11681194
function getCompressionProgram() {
11691195
switch (compressionMethod) {
11701196
case constants_1.CompressionMethod.Zstd:
1171-
return ['--use-compress-program', 'zstd -d --long=30'];
1197+
return ['--use-compress-program', 'unzstd --long=30'];
11721198
case constants_1.CompressionMethod.ZstdWithoutLong:
1173-
return ['--use-compress-program', 'zstd -d'];
1199+
return ['--use-compress-program', 'unzstd'];
11741200
default:
11751201
return ['-z'];
11761202
}
@@ -1235,7 +1261,8 @@ function getDownloadOptions(copy) {
12351261
const result = {
12361262
useAzureSdk: true,
12371263
downloadConcurrency: 8,
1238-
timeoutInMs: 30000
1264+
timeoutInMs: 30000,
1265+
segmentTimeoutInMs: 3600000
12391266
};
12401267
if (copy) {
12411268
if (typeof copy.useAzureSdk === 'boolean') {
@@ -1247,10 +1274,14 @@ function getDownloadOptions(copy) {
12471274
if (typeof copy.timeoutInMs === 'number') {
12481275
result.timeoutInMs = copy.timeoutInMs;
12491276
}
1277+
if (typeof copy.segmentTimeoutInMs === 'number') {
1278+
result.segmentTimeoutInMs = copy.segmentTimeoutInMs;
1279+
}
12501280
}
12511281
core.debug(`Use Azure SDK: ${result.useAzureSdk}`);
12521282
core.debug(`Download concurrency: ${result.downloadConcurrency}`);
12531283
core.debug(`Request timeout (ms): ${result.timeoutInMs}`);
1284+
core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`);
12541285
return result;
12551286
}
12561287
exports.getDownloadOptions = getDownloadOptions;

dist/run/index.js

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,13 @@ function resolvePaths(patterns) {
525525
.replace(new RegExp(`\\${path.sep}`, 'g'), '/');
526526
core.debug(`Matched: ${relativeFile}`);
527527
// Paths are made relative so the tar entries are all relative to the root of the workspace.
528-
paths.push(`${relativeFile}`);
528+
if (relativeFile === '') {
529+
// path.relative returns empty string if workspace and file are equal
530+
paths.push('.');
531+
}
532+
else {
533+
paths.push(`${relativeFile}`);
534+
}
529535
}
530536
}
531537
catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -683,6 +689,7 @@ const util = __importStar(__nccwpck_require__(3837));
683689
const utils = __importStar(__nccwpck_require__(1518));
684690
const constants_1 = __nccwpck_require__(8840);
685691
const requestUtils_1 = __nccwpck_require__(3981);
692+
const abort_controller_1 = __nccwpck_require__(2557);
686693
/**
687694
* Pipes the body of a HTTP response to a stream
688695
*
@@ -866,15 +873,24 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
866873
const fd = fs.openSync(archivePath, 'w');
867874
try {
868875
downloadProgress.startDisplayTimer();
876+
const controller = new abort_controller_1.AbortController();
877+
const abortSignal = controller.signal;
869878
while (!downloadProgress.isDone()) {
870879
const segmentStart = downloadProgress.segmentOffset + downloadProgress.segmentSize;
871880
const segmentSize = Math.min(maxSegmentSize, contentLength - segmentStart);
872881
downloadProgress.nextSegment(segmentSize);
873-
const result = yield client.downloadToBuffer(segmentStart, segmentSize, {
882+
const result = yield promiseWithTimeout(options.segmentTimeoutInMs || 3600000, client.downloadToBuffer(segmentStart, segmentSize, {
883+
abortSignal,
874884
concurrency: options.downloadConcurrency,
875885
onProgress: downloadProgress.onProgress()
876-
});
877-
fs.writeFileSync(fd, result);
886+
}));
887+
if (result === 'timeout') {
888+
controller.abort();
889+
throw new Error('Aborting cache download as the download time exceeded the timeout.');
890+
}
891+
else if (Buffer.isBuffer(result)) {
892+
fs.writeFileSync(fd, result);
893+
}
878894
}
879895
}
880896
finally {
@@ -885,6 +901,16 @@ function downloadCacheStorageSDK(archiveLocation, archivePath, options) {
885901
});
886902
}
887903
exports.downloadCacheStorageSDK = downloadCacheStorageSDK;
904+
const promiseWithTimeout = (timeoutMs, promise) => __awaiter(void 0, void 0, void 0, function* () {
905+
let timeoutHandle;
906+
const timeoutPromise = new Promise(resolve => {
907+
timeoutHandle = setTimeout(() => resolve('timeout'), timeoutMs);
908+
});
909+
return Promise.race([promise, timeoutPromise]).then(result => {
910+
clearTimeout(timeoutHandle);
911+
return result;
912+
});
913+
});
888914
//# sourceMappingURL=downloadUtils.js.map
889915

890916
/***/ }),
@@ -1102,9 +1128,9 @@ function extractTar(archivePath, compressionMethod) {
11021128
function getCompressionProgram() {
11031129
switch (compressionMethod) {
11041130
case constants_1.CompressionMethod.Zstd:
1105-
return ['--use-compress-program', 'zstd -d --long=30'];
1131+
return ['--use-compress-program', 'unzstd --long=30'];
11061132
case constants_1.CompressionMethod.ZstdWithoutLong:
1107-
return ['--use-compress-program', 'zstd -d'];
1133+
return ['--use-compress-program', 'unzstd'];
11081134
default:
11091135
return ['-z'];
11101136
}
@@ -1135,9 +1161,9 @@ function createTar(archiveFolder, sourceDirectories, compressionMethod) {
11351161
function getCompressionProgram() {
11361162
switch (compressionMethod) {
11371163
case constants_1.CompressionMethod.Zstd:
1138-
return ['--use-compress-program', 'zstd -T0 --long=30'];
1164+
return ['--use-compress-program', 'zstdmt --long=30'];
11391165
case constants_1.CompressionMethod.ZstdWithoutLong:
1140-
return ['--use-compress-program', 'zstd -T0'];
1166+
return ['--use-compress-program', 'zstdmt'];
11411167
default:
11421168
return ['-z'];
11431169
}
@@ -1168,9 +1194,9 @@ function listTar(archivePath, compressionMethod) {
11681194
function getCompressionProgram() {
11691195
switch (compressionMethod) {
11701196
case constants_1.CompressionMethod.Zstd:
1171-
return ['--use-compress-program', 'zstd -d --long=30'];
1197+
return ['--use-compress-program', 'unzstd --long=30'];
11721198
case constants_1.CompressionMethod.ZstdWithoutLong:
1173-
return ['--use-compress-program', 'zstd -d'];
1199+
return ['--use-compress-program', 'unzstd'];
11741200
default:
11751201
return ['-z'];
11761202
}
@@ -1235,7 +1261,8 @@ function getDownloadOptions(copy) {
12351261
const result = {
12361262
useAzureSdk: true,
12371263
downloadConcurrency: 8,
1238-
timeoutInMs: 30000
1264+
timeoutInMs: 30000,
1265+
segmentTimeoutInMs: 3600000
12391266
};
12401267
if (copy) {
12411268
if (typeof copy.useAzureSdk === 'boolean') {
@@ -1247,10 +1274,14 @@ function getDownloadOptions(copy) {
12471274
if (typeof copy.timeoutInMs === 'number') {
12481275
result.timeoutInMs = copy.timeoutInMs;
12491276
}
1277+
if (typeof copy.segmentTimeoutInMs === 'number') {
1278+
result.segmentTimeoutInMs = copy.segmentTimeoutInMs;
1279+
}
12501280
}
12511281
core.debug(`Use Azure SDK: ${result.useAzureSdk}`);
12521282
core.debug(`Download concurrency: ${result.downloadConcurrency}`);
12531283
core.debug(`Request timeout (ms): ${result.timeoutInMs}`);
1284+
core.debug(`Segment download timeout (ms): ${result.segmentTimeoutInMs}`);
12541285
return result;
12551286
}
12561287
exports.getDownloadOptions = getDownloadOptions;

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
@@ -24,7 +24,7 @@
2424
"author": "golangci",
2525
"license": "MIT",
2626
"dependencies": {
27-
"@actions/cache": "^3.0.0",
27+
"@actions/cache": "^3.0.3",
2828
"@actions/core": "^1.9.1",
2929
"@actions/exec": "^1.1.1",
3030
"@actions/github": "^5.0.3",

0 commit comments

Comments
 (0)