1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-05-02 16:29:54 +02:00

Merge master into ethanis/cache-multiple-paths

This commit is contained in:
Ethan Dennis 2020-03-18 17:35:59 -07:00
commit f68f5d03cc
No known key found for this signature in database
GPG key ID: 32E74B75DB4065DD
15 changed files with 3437 additions and 602 deletions

33
dist/restore/index.js vendored
View file

@ -2184,8 +2184,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(__webpack_require__(470));
const fs = __importStar(__webpack_require__(747));
const crypto = __importStar(__webpack_require__(417));
const auth_1 = __webpack_require__(226);
const http_client_1 = __webpack_require__(539);
const auth_1 = __webpack_require__(226);
const utils = __importStar(__webpack_require__(443));
const constants_1 = __webpack_require__(694);
const versionSalt = "1.0";
@ -3189,6 +3189,7 @@ const io = __importStar(__webpack_require__(1));
const glob = __importStar(__webpack_require__(281));
const fs = __importStar(__webpack_require__(747));
const path = __importStar(__webpack_require__(622));
const util = __importStar(__webpack_require__(669));
const uuidV4 = __importStar(__webpack_require__(826));
const constants_1 = __webpack_require__(694);
// From https://github.com/actions/toolkit/blob/master/packages/tool-cache/src/tool-cache.ts#L23
@ -3299,6 +3300,10 @@ function isValidEvent() {
return getSupportedEvents().includes(githubEvent);
}
exports.isValidEvent = isValidEvent;
function unlinkFile(path) {
return util.promisify(fs.unlink)(path);
}
exports.unlinkFile = unlinkFile;
/***/ }),
@ -4595,11 +4600,22 @@ function run() {
core.debug(`Archive Path: ${archivePath}`);
// Store the cache result
utils.setCacheState(cacheEntry);
// Download the cache from the cache entry
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath);
const archiveFileSize = utils.getArchiveFileSize(archivePath);
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
yield tar_1.extractTar(archivePath);
try {
// Download the cache from the cache entry
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath);
const archiveFileSize = utils.getArchiveFileSize(archivePath);
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
yield tar_1.extractTar(archivePath);
}
finally {
// Try to delete the archive to save space
try {
yield utils.unlinkFile(archivePath);
}
catch (error) {
core.debug(`Failed to delete archive: ${error}`);
}
}
const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheEntry);
utils.setCacheHitOutput(isExactKeyMatch);
core.info(`Cache restored from key: ${cacheEntry && cacheEntry.cacheKey}`);
@ -4943,11 +4959,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const exec_1 = __webpack_require__(986);
const io = __importStar(__webpack_require__(1));
const fs_1 = __webpack_require__(747);
const path = __importStar(__webpack_require__(622));
const constants_1 = __webpack_require__(694);
const exec_1 = __webpack_require__(986);
const fs_1 = __webpack_require__(747);
function getTarPath() {
return __awaiter(this, void 0, void 0, function* () {
// Explicitly use BSD Tar on Windows
@ -4968,7 +4984,6 @@ function execTar(args, cwd) {
yield exec_1.exec(`"${yield getTarPath()}"`, args, { cwd: cwd });
}
catch (error) {
console.log("error", error);
const IS_WINDOWS = process.platform === "win32";
if (IS_WINDOWS) {
throw new Error(`Tar failed with error: ${(_a = error) === null || _a === void 0 ? void 0 : _a.message}. Ensure BSD tar is installed and on the PATH.`);