@@ -97,7 +97,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
9797 if (core.isDebug()) {
9898 yield tar_1.listTar(archivePath, compressionMethod);
9999 }
100- const archiveFileSize = utils.getArchiveFileSizeIsBytes (archivePath);
100+ const archiveFileSize = utils.getArchiveFileSizeInBytes (archivePath);
101101 core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
102102 yield tar_1.extractTar(archivePath, compressionMethod);
103103 core.info('Cache restored successfully');
@@ -142,18 +142,29 @@ function saveCache(paths, key, options) {
142142 const archiveFolder = yield utils.createTempDirectory();
143143 const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
144144 core.debug(`Archive Path: ${archivePath}`);
145- yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
146- if (core.isDebug()) {
147- yield tar_1.listTar(archivePath, compressionMethod);
145+ try {
146+ yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
147+ if (core.isDebug()) {
148+ yield tar_1.listTar(archivePath, compressionMethod);
149+ }
150+ const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
151+ const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
152+ core.debug(`File Size: ${archiveFileSize}`);
153+ if (archiveFileSize > fileSizeLimit) {
154+ throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
155+ }
156+ core.debug(`Saving Cache (ID: ${cacheId})`);
157+ yield cacheHttpClient.saveCache(cacheId, archivePath, options);
148158 }
149- const fileSizeLimit = 5 * 1024 * 1024 * 1024; // 5GB per repo limit
150- const archiveFileSize = utils.getArchiveFileSizeIsBytes(archivePath);
151- core.debug(`File Size: ${archiveFileSize}`);
152- if (archiveFileSize > fileSizeLimit) {
153- throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 5GB limit, not saving cache.`);
159+ finally {
160+ // Try to delete the archive to save space
161+ try {
162+ yield utils.unlinkFile(archivePath);
163+ }
164+ catch (error) {
165+ core.debug(`Failed to delete archive: ${error}`);
166+ }
154167 }
155- core.debug(`Saving Cache (ID: ${cacheId})`);
156- yield cacheHttpClient.saveCache(cacheId, archivePath, options);
157168 return cacheId;
158169 });
159170}
@@ -321,7 +332,7 @@ function uploadChunk(httpClient, resourceUrl, openStream, start, end) {
321332function uploadFile(httpClient, cacheId, archivePath, options) {
322333 return __awaiter(this, void 0, void 0, function* () {
323334 // Upload Chunks
324- const fileSize = fs.statSync (archivePath).size ;
335+ const fileSize = utils.getArchiveFileSizeInBytes (archivePath);
325336 const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`);
326337 const fd = fs.openSync(archivePath, 'r');
327338 const uploadOptions = options_1.getUploadOptions(options);
@@ -371,7 +382,7 @@ function saveCache(cacheId, archivePath, options) {
371382 yield uploadFile(httpClient, cacheId, archivePath, options);
372383 // Commit Cache
373384 core.debug('Commiting cache');
374- const cacheSize = utils.getArchiveFileSizeIsBytes (archivePath);
385+ const cacheSize = utils.getArchiveFileSizeInBytes (archivePath);
375386 core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
376387 const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
377388 if (!requestUtils_1.isSuccessStatusCode(commitCacheResponse.statusCode)) {
@@ -451,10 +462,10 @@ function createTempDirectory() {
451462 });
452463}
453464exports.createTempDirectory = createTempDirectory;
454- function getArchiveFileSizeIsBytes (filePath) {
465+ function getArchiveFileSizeInBytes (filePath) {
455466 return fs.statSync(filePath).size;
456467}
457- exports.getArchiveFileSizeIsBytes = getArchiveFileSizeIsBytes ;
468+ exports.getArchiveFileSizeInBytes = getArchiveFileSizeInBytes ;
458469function resolvePaths(patterns) {
459470 var e_1, _a;
460471 var _b;
@@ -759,7 +770,7 @@ function downloadCacheHttpClient(archiveLocation, archivePath) {
759770 const contentLengthHeader = downloadResponse.message.headers['content-length'];
760771 if (contentLengthHeader) {
761772 const expectedLength = parseInt(contentLengthHeader);
762- const actualLength = utils.getArchiveFileSizeIsBytes (archivePath);
773+ const actualLength = utils.getArchiveFileSizeInBytes (archivePath);
763774 if (actualLength !== expectedLength) {
764775 throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`);
765776 }
@@ -67770,8 +67781,8 @@ exports.toRemoteCache = exports.fromRemoteCache = exports.toLocalCache = exports
6777067781const cache_1 = __nccwpck_require__(7799);
6777167782const core = __importStar(__nccwpck_require__(2186));
6777267783const toolCache = __importStar(__nccwpck_require__(7784));
67773- const path_1 = __importDefault(__nccwpck_require__(1017));
6777467784const os_1 = __importDefault(__nccwpck_require__(2037));
67785+ const path_1 = __importDefault(__nccwpck_require__(1017));
6777567786/**
6777667787 * Get the path to the `expo-cli` from cache, if any.
6777767788 * Note, this cache is **NOT** shared between jobs.
0 commit comments