@@ -1041,10 +1041,10 @@ function createTempDirectory() {
1041
1041
});
1042
1042
}
1043
1043
exports.createTempDirectory = createTempDirectory;
1044
- function getArchiveFileSizeIsBytes (filePath) {
1044
+ function getArchiveFileSizeInBytes (filePath) {
1045
1045
return fs.statSync(filePath).size;
1046
1046
}
1047
- exports.getArchiveFileSizeIsBytes = getArchiveFileSizeIsBytes ;
1047
+ exports.getArchiveFileSizeInBytes = getArchiveFileSizeInBytes ;
1048
1048
function resolvePaths(patterns) {
1049
1049
var e_1, _a;
1050
1050
var _b;
@@ -3852,7 +3852,7 @@ function uploadChunk(httpClient, resourceUrl, openStream, start, end) {
3852
3852
function uploadFile(httpClient, cacheId, archivePath, options) {
3853
3853
return __awaiter(this, void 0, void 0, function* () {
3854
3854
// Upload Chunks
3855
- const fileSize = fs.statSync (archivePath).size ;
3855
+ const fileSize = utils.getArchiveFileSizeInBytes (archivePath);
3856
3856
const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`);
3857
3857
const fd = fs.openSync(archivePath, 'r');
3858
3858
const uploadOptions = options_1.getUploadOptions(options);
@@ -3902,7 +3902,7 @@ function saveCache(cacheId, archivePath, options) {
3902
3902
yield uploadFile(httpClient, cacheId, archivePath, options);
3903
3903
// Commit Cache
3904
3904
core.debug('Commiting cache');
3905
- const cacheSize = utils.getArchiveFileSizeIsBytes (archivePath);
3905
+ const cacheSize = utils.getArchiveFileSizeInBytes (archivePath);
3906
3906
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
3907
3907
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
3908
3908
if (!requestUtils_1.isSuccessStatusCode(commitCacheResponse.statusCode)) {
@@ -5877,7 +5877,7 @@ function downloadCacheHttpClient(archiveLocation, archivePath) {
5877
5877
const contentLengthHeader = downloadResponse.message.headers['content-length'];
5878
5878
if (contentLengthHeader) {
5879
5879
const expectedLength = parseInt(contentLengthHeader);
5880
- const actualLength = utils.getArchiveFileSizeIsBytes (archivePath);
5880
+ const actualLength = utils.getArchiveFileSizeInBytes (archivePath);
5881
5881
if (actualLength !== expectedLength) {
5882
5882
throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`);
5883
5883
}
@@ -34322,7 +34322,7 @@ Object.defineProperty(Response.prototype, Symbol.toStringTag, {
34322
34322
});
34323
34323
34324
34324
const INTERNALS$2 = Symbol('Request internals');
34325
- const URL = whatwgUrl.URL;
34325
+ const URL = Url.URL || whatwgUrl.URL;
34326
34326
34327
34327
// fix an issue where "format", "parse" aren't a named export for node <10
34328
34328
const parse_url = Url.parse;
@@ -41451,7 +41451,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
41451
41451
if (core.isDebug()) {
41452
41452
yield tar_1.listTar(archivePath, compressionMethod);
41453
41453
}
41454
- const archiveFileSize = utils.getArchiveFileSizeIsBytes (archivePath);
41454
+ const archiveFileSize = utils.getArchiveFileSizeInBytes (archivePath);
41455
41455
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
41456
41456
yield tar_1.extractTar(archivePath, compressionMethod);
41457
41457
core.info('Cache restored successfully');
@@ -41496,18 +41496,29 @@ function saveCache(paths, key, options) {
41496
41496
const archiveFolder = yield utils.createTempDirectory();
41497
41497
const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
41498
41498
core.debug(`Archive Path: ${archivePath}`);
41499
- yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
41500
- if (core.isDebug()) {
41501
- yield tar_1.listTar(archivePath, compressionMethod);
41502
- }
41503
- const fileSizeLimit = 5 * 1024 * 1024 * 1024; // 5GB per repo limit
41504
- const archiveFileSize = utils.getArchiveFileSizeIsBytes(archivePath);
41505
- core.debug(`File Size: ${archiveFileSize}`);
41506
- if (archiveFileSize > fileSizeLimit) {
41507
- throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 5GB limit, not saving cache.`);
41508
- }
41509
- core.debug(`Saving Cache (ID: ${cacheId})`);
41510
- yield cacheHttpClient.saveCache(cacheId, archivePath, options);
41499
+ try {
41500
+ yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
41501
+ if (core.isDebug()) {
41502
+ yield tar_1.listTar(archivePath, compressionMethod);
41503
+ }
41504
+ const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
41505
+ const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
41506
+ core.debug(`File Size: ${archiveFileSize}`);
41507
+ if (archiveFileSize > fileSizeLimit) {
41508
+ throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
41509
+ }
41510
+ core.debug(`Saving Cache (ID: ${cacheId})`);
41511
+ yield cacheHttpClient.saveCache(cacheId, archivePath, options);
41512
+ }
41513
+ finally {
41514
+ // Try to delete the archive to save space
41515
+ try {
41516
+ yield utils.unlinkFile(archivePath);
41517
+ }
41518
+ catch (error) {
41519
+ core.debug(`Failed to delete archive: ${error}`);
41520
+ }
41521
+ }
41511
41522
return cacheId;
41512
41523
});
41513
41524
}
@@ -53218,7 +53229,12 @@ class HttpHeaders {
53218
53229
* Create a deep clone/copy of this HttpHeaders collection.
53219
53230
*/
53220
53231
clone() {
53221
- return new HttpHeaders(this.rawHeaders());
53232
+ const resultPreservingCasing = {};
53233
+ for (const headerKey in this._headersMap) {
53234
+ const header = this._headersMap[headerKey];
53235
+ resultPreservingCasing[header.name] = header.value;
53236
+ }
53237
+ return new HttpHeaders(resultPreservingCasing);
53222
53238
}
53223
53239
}
53224
53240
@@ -53255,7 +53271,7 @@ const Constants = {
53255
53271
/**
53256
53272
* The core-http version
53257
53273
*/
53258
- coreHttpVersion: "2.2.1 ",
53274
+ coreHttpVersion: "2.2.2 ",
53259
53275
/**
53260
53276
* Specifies HTTP.
53261
53277
*/
@@ -55568,7 +55584,7 @@ class FetchHttpClient {
55568
55584
}
55569
55585
let downloadStreamDone = Promise.resolve();
55570
55586
if (isReadableStream(operationResponse === null || operationResponse === void 0 ? void 0 : operationResponse.readableStreamBody)) {
55571
- downloadStreamDone = isStreamComplete(operationResponse.readableStreamBody);
55587
+ downloadStreamDone = isStreamComplete(operationResponse.readableStreamBody, abortController$1 );
55572
55588
}
55573
55589
Promise.all([uploadStreamDone, downloadStreamDone])
55574
55590
.then(() => {
@@ -55586,11 +55602,14 @@ class FetchHttpClient {
55586
55602
function isReadableStream(body) {
55587
55603
return body && typeof body.pipe === "function";
55588
55604
}
55589
- function isStreamComplete(stream) {
55605
+ function isStreamComplete(stream, aborter ) {
55590
55606
return new Promise((resolve) => {
55591
- stream.on("close", resolve);
55592
- stream.on("end", resolve);
55593
- stream.on("error", resolve);
55607
+ stream.once("close", () => {
55608
+ aborter === null || aborter === void 0 ? void 0 : aborter.abort();
55609
+ resolve();
55610
+ });
55611
+ stream.once("end", resolve);
55612
+ stream.once("error", resolve);
55594
55613
});
55595
55614
}
55596
55615
function parseHeaders(headers) {
0 commit comments