1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2024-11-24 04:29:16 +01:00
This commit is contained in:
Shubham Tiwari 2022-06-30 09:36:52 +00:00 committed by GitHub
parent d351e68b9a
commit aeb01573e6
2 changed files with 26 additions and 75 deletions

32
dist/restore/index.js vendored
View file

@ -46850,8 +46850,6 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
checkKey(key); checkKey(key);
} }
const compressionMethod = yield utils.getCompressionMethod(); const compressionMethod = yield utils.getCompressionMethod();
let archivePath = '';
try {
// path are needed to compute version // path are needed to compute version
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
compressionMethod compressionMethod
@ -46860,8 +46858,9 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
// Cache not found // Cache not found
return undefined; return undefined;
} }
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); const archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
core.debug(`Archive Path: ${archivePath}`); core.debug(`Archive Path: ${archivePath}`);
try {
// Download the cache from the cache entry // Download the cache from the cache entry
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
if (core.isDebug()) { if (core.isDebug()) {
@ -46871,17 +46870,6 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
yield tar_1.extractTar(archivePath, compressionMethod); yield tar_1.extractTar(archivePath, compressionMethod);
core.info('Cache restored successfully'); core.info('Cache restored successfully');
return cacheEntry.cacheKey;
}
catch (error) {
const typedError = error;
if (typedError.name === ValidationError.name) {
throw error;
}
else {
// Supress all non-validation cache related errors because caching should be optional
core.warning(`Failed to restore: ${error.message}`);
}
} }
finally { finally {
// Try to delete the archive to save space // Try to delete the archive to save space
@ -46892,7 +46880,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
core.debug(`Failed to delete archive: ${error}`); core.debug(`Failed to delete archive: ${error}`);
} }
} }
return undefined; return cacheEntry.cacheKey;
}); });
} }
exports.restoreCache = restoreCache; exports.restoreCache = restoreCache;
@ -46910,7 +46898,7 @@ function saveCache(paths, key, options) {
checkPaths(paths); checkPaths(paths);
checkKey(key); checkKey(key);
const compressionMethod = yield utils.getCompressionMethod(); const compressionMethod = yield utils.getCompressionMethod();
let cacheId = -1; let cacheId = null;
const cachePaths = yield utils.resolvePaths(paths); const cachePaths = yield utils.resolvePaths(paths);
core.debug('Cache Paths:'); core.debug('Cache Paths:');
core.debug(`${JSON.stringify(cachePaths)}`); core.debug(`${JSON.stringify(cachePaths)}`);
@ -46949,18 +46937,6 @@ function saveCache(paths, key, options) {
core.debug(`Saving Cache (ID: ${cacheId})`); core.debug(`Saving Cache (ID: ${cacheId})`);
yield cacheHttpClient.saveCache(cacheId, archivePath, options); yield cacheHttpClient.saveCache(cacheId, archivePath, options);
} }
catch (error) {
const typedError = error;
if (typedError.name === ValidationError.name) {
throw error;
}
else if (typedError.name === ReserveCacheError.name) {
core.info(`Failed to save: ${typedError.message}`);
}
else {
core.warning(`Failed to save: ${typedError.message}`);
}
}
finally { finally {
// Try to delete the archive to save space // Try to delete the archive to save space
try { try {

37
dist/save/index.js vendored
View file

@ -46795,11 +46795,10 @@ function run() {
const cacheId = yield cache.saveCache(cachePaths, primaryKey, { const cacheId = yield cache.saveCache(cachePaths, primaryKey, {
uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize)
}); });
if (cacheId == -1) { if (cacheId != -1) {
return;
}
core.info(`Cache saved with key: ${primaryKey}`); core.info(`Cache saved with key: ${primaryKey}`);
} }
}
catch (error) { catch (error) {
utils.logWarning(error.message); utils.logWarning(error.message);
} }
@ -46937,8 +46936,6 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
checkKey(key); checkKey(key);
} }
const compressionMethod = yield utils.getCompressionMethod(); const compressionMethod = yield utils.getCompressionMethod();
let archivePath = '';
try {
// path are needed to compute version // path are needed to compute version
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
compressionMethod compressionMethod
@ -46947,8 +46944,9 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
// Cache not found // Cache not found
return undefined; return undefined;
} }
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); const archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
core.debug(`Archive Path: ${archivePath}`); core.debug(`Archive Path: ${archivePath}`);
try {
// Download the cache from the cache entry // Download the cache from the cache entry
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options); yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
if (core.isDebug()) { if (core.isDebug()) {
@ -46958,17 +46956,6 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`); core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
yield tar_1.extractTar(archivePath, compressionMethod); yield tar_1.extractTar(archivePath, compressionMethod);
core.info('Cache restored successfully'); core.info('Cache restored successfully');
return cacheEntry.cacheKey;
}
catch (error) {
const typedError = error;
if (typedError.name === ValidationError.name) {
throw error;
}
else {
// Supress all non-validation cache related errors because caching should be optional
core.warning(`Failed to restore: ${error.message}`);
}
} }
finally { finally {
// Try to delete the archive to save space // Try to delete the archive to save space
@ -46979,7 +46966,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
core.debug(`Failed to delete archive: ${error}`); core.debug(`Failed to delete archive: ${error}`);
} }
} }
return undefined; return cacheEntry.cacheKey;
}); });
} }
exports.restoreCache = restoreCache; exports.restoreCache = restoreCache;
@ -46997,7 +46984,7 @@ function saveCache(paths, key, options) {
checkPaths(paths); checkPaths(paths);
checkKey(key); checkKey(key);
const compressionMethod = yield utils.getCompressionMethod(); const compressionMethod = yield utils.getCompressionMethod();
let cacheId = -1; let cacheId = null;
const cachePaths = yield utils.resolvePaths(paths); const cachePaths = yield utils.resolvePaths(paths);
core.debug('Cache Paths:'); core.debug('Cache Paths:');
core.debug(`${JSON.stringify(cachePaths)}`); core.debug(`${JSON.stringify(cachePaths)}`);
@ -47036,18 +47023,6 @@ function saveCache(paths, key, options) {
core.debug(`Saving Cache (ID: ${cacheId})`); core.debug(`Saving Cache (ID: ${cacheId})`);
yield cacheHttpClient.saveCache(cacheId, archivePath, options); yield cacheHttpClient.saveCache(cacheId, archivePath, options);
} }
catch (error) {
const typedError = error;
if (typedError.name === ValidationError.name) {
throw error;
}
else if (typedError.name === ReserveCacheError.name) {
core.info(`Failed to save: ${typedError.message}`);
}
else {
core.warning(`Failed to save: ${typedError.message}`);
}
}
finally { finally {
// Try to delete the archive to save space // Try to delete the archive to save space
try { try {