diff --git a/action.yml b/action.yml index 23d6f05..a8a25fe 100644 --- a/action.yml +++ b/action.yml @@ -1,13 +1,13 @@ name: "MinIO Cache" -description: "Save and restore caches, inkl. restore-keys Support." +description: "Save and restore caches via MinIO/S3." author: "0xMax42" branding: icon: "archive" color: "blue" inputs: - keys: - description: "List of cache keys, first is primary key, others are fallbacks" + key: + description: "Unique cache key to identify the cache" required: true paths: description: "List of paths to cache" diff --git a/dist/index.js b/dist/index.js index 41e677b..bf9ac39 100644 --- a/dist/index.js +++ b/dist/index.js @@ -96,11 +96,11 @@ var require_command = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.issue = exports2.issueCommand = void 0; - var os2 = __importStar(require("os")); + var os = __importStar(require("os")); var utils_1 = require_utils(); function issueCommand(command, properties, message) { const cmd = new Command(command, properties, message); - process.stdout.write(cmd.toString() + os2.EOL); + process.stdout.write(cmd.toString() + os.EOL); } exports2.issueCommand = issueCommand; function issue(name2, message = "") { @@ -184,7 +184,7 @@ var require_file_command = __commonJS({ exports2.prepareKeyValueMessage = exports2.issueFileCommand = void 0; var crypto = __importStar(require("crypto")); var fs15 = __importStar(require("fs")); - var os2 = __importStar(require("os")); + var os = __importStar(require("os")); var utils_1 = require_utils(); function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; @@ -194,7 +194,7 @@ var require_file_command = __commonJS({ if (!fs15.existsSync(filePath)) { throw new Error(`Missing file at path: ${filePath}`); } - fs15.appendFileSync(filePath, `${(0, utils_1.toCommandValue)(message)}${os2.EOL}`, { + fs15.appendFileSync(filePath, `${(0, utils_1.toCommandValue)(message)}${os.EOL}`, { encoding: "utf8" }); } @@ -208,7 +208,7 @@ var require_file_command = __commonJS({ if (convertedValue.includes(delimiter)) { throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); } - return `${key}<<${delimiter}${os2.EOL}${convertedValue}${os2.EOL}${delimiter}`; + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; } exports2.prepareKeyValueMessage = prepareKeyValueMessage; } @@ -997,14 +997,14 @@ var require_util = __commonJS({ } const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80; let origin = url.origin != null ? url.origin : `${url.protocol}//${url.hostname}:${port}`; - let path10 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`; + let path9 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`; if (origin.endsWith("/")) { origin = origin.substring(0, origin.length - 1); } - if (path10 && !path10.startsWith("/")) { - path10 = `/${path10}`; + if (path9 && !path9.startsWith("/")) { + path9 = `/${path9}`; } - url = new URL(origin + path10); + url = new URL(origin + path9); } return url; } @@ -2618,20 +2618,20 @@ var require_parseParams = __commonJS({ var require_basename = __commonJS({ "node_modules/@fastify/busboy/lib/utils/basename.js"(exports2, module2) { "use strict"; - module2.exports = function basename2(path10) { - if (typeof path10 !== "string") { + module2.exports = function basename2(path9) { + if (typeof path9 !== "string") { return ""; } - for (var i2 = path10.length - 1; i2 >= 0; --i2) { - switch (path10.charCodeAt(i2)) { + for (var i2 = path9.length - 1; i2 >= 0; --i2) { + switch (path9.charCodeAt(i2)) { case 47: // '/' case 92: - path10 = path10.slice(i2 + 1); - return path10 === ".." || path10 === "." ? "" : path10; + path9 = path9.slice(i2 + 1); + return path9 === ".." || path9 === "." ? "" : path9; } } - return path10 === ".." || path10 === "." ? "" : path10; + return path9 === ".." || path9 === "." ? "" : path9; }; } }); @@ -5661,7 +5661,7 @@ var require_request = __commonJS({ } var Request2 = class _Request { constructor(origin, { - path: path10, + path: path9, method, body, headers, @@ -5675,11 +5675,11 @@ var require_request = __commonJS({ throwOnError, expectContinue }, handler) { - if (typeof path10 !== "string") { + if (typeof path9 !== "string") { throw new InvalidArgumentError("path must be a string"); - } else if (path10[0] !== "/" && !(path10.startsWith("http://") || path10.startsWith("https://")) && method !== "CONNECT") { + } else if (path9[0] !== "/" && !(path9.startsWith("http://") || path9.startsWith("https://")) && method !== "CONNECT") { throw new InvalidArgumentError("path must be an absolute URL or start with a slash"); - } else if (invalidPathRegex.exec(path10) !== null) { + } else if (invalidPathRegex.exec(path9) !== null) { throw new InvalidArgumentError("invalid request path"); } if (typeof method !== "string") { @@ -5742,7 +5742,7 @@ var require_request = __commonJS({ this.completed = false; this.aborted = false; this.upgrade = upgrade || null; - this.path = query ? util.buildURL(path10, query) : path10; + this.path = query ? util.buildURL(path9, query) : path9; this.origin = origin; this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent; this.blocking = blocking == null ? false : blocking; @@ -6750,9 +6750,9 @@ var require_RedirectHandler = __commonJS({ return this.handler.onHeaders(statusCode, headers, resume, statusText); } const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin))); - const path10 = search ? `${pathname}${search}` : pathname; + const path9 = search ? `${pathname}${search}` : pathname; this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin); - this.opts.path = path10; + this.opts.path = path9; this.opts.origin = origin; this.opts.maxRedirections = 0; this.opts.query = null; @@ -7992,7 +7992,7 @@ var require_client = __commonJS({ writeH2(client, client[kHTTP2Session], request); return; } - const { body, method, path: path10, host, upgrade, headers, blocking, reset } = request; + const { body, method, path: path9, host, upgrade, headers, blocking, reset } = request; const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH"; if (body && typeof body.read === "function") { body.read(0); @@ -8042,7 +8042,7 @@ var require_client = __commonJS({ if (blocking) { socket[kBlocking] = true; } - let header = `${method} ${path10} HTTP/1.1\r + let header = `${method} ${path9} HTTP/1.1\r `; if (typeof host === "string") { header += `host: ${host}\r @@ -8105,7 +8105,7 @@ upgrade: ${upgrade}\r return true; } function writeH2(client, session, request) { - const { body, method, path: path10, host, upgrade, expectContinue, signal, headers: reqHeaders } = request; + const { body, method, path: path9, host, upgrade, expectContinue, signal, headers: reqHeaders } = request; let headers; if (typeof reqHeaders === "string") headers = Request2[kHTTP2CopyHeaders](reqHeaders.trim()); else headers = reqHeaders; @@ -8148,7 +8148,7 @@ upgrade: ${upgrade}\r }); return true; } - headers[HTTP2_HEADER_PATH] = path10; + headers[HTTP2_HEADER_PATH] = path9; headers[HTTP2_HEADER_SCHEME] = "https"; const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH"; if (body && typeof body.read === "function") { @@ -10388,20 +10388,20 @@ var require_mock_utils = __commonJS({ } return true; } - function safeUrl(path10) { - if (typeof path10 !== "string") { - return path10; + function safeUrl(path9) { + if (typeof path9 !== "string") { + return path9; } - const pathSegments = path10.split("?"); + const pathSegments = path9.split("?"); if (pathSegments.length !== 2) { - return path10; + return path9; } const qp = new URLSearchParams(pathSegments.pop()); qp.sort(); return [...pathSegments, qp.toString()].join("?"); } - function matchKey(mockDispatch2, { path: path10, method, body, headers }) { - const pathMatch = matchValue(mockDispatch2.path, path10); + function matchKey(mockDispatch2, { path: path9, method, body, headers }) { + const pathMatch = matchValue(mockDispatch2.path, path9); const methodMatch = matchValue(mockDispatch2.method, method); const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true; const headersMatch = matchHeaders(mockDispatch2, headers); @@ -10419,7 +10419,7 @@ var require_mock_utils = __commonJS({ function getMockDispatch(mockDispatches, key) { const basePath = key.query ? buildURL(key.path, key.query) : key.path; const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath; - let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path10 }) => matchValue(safeUrl(path10), resolvedPath)); + let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path9 }) => matchValue(safeUrl(path9), resolvedPath)); if (matchedMockDispatches.length === 0) { throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`); } @@ -10456,9 +10456,9 @@ var require_mock_utils = __commonJS({ } } function buildKey(opts) { - const { path: path10, method, body, headers, query } = opts; + const { path: path9, method, body, headers, query } = opts; return { - path: path10, + path: path9, method, body, headers, @@ -10907,10 +10907,10 @@ var require_pending_interceptors_formatter = __commonJS({ } format(pendingInterceptors) { const withPrettyHeaders = pendingInterceptors.map( - ({ method, path: path10, data: { statusCode }, persist, times, timesInvoked, origin }) => ({ + ({ method, path: path9, data: { statusCode }, persist, times, timesInvoked, origin }) => ({ Method: method, Origin: origin, - Path: path10, + Path: path9, "Status code": statusCode, Persistent: persist ? "\u2705" : "\u274C", Invocations: timesInvoked, @@ -15530,8 +15530,8 @@ var require_util6 = __commonJS({ } } } - function validateCookiePath(path10) { - for (const char of path10) { + function validateCookiePath(path9) { + for (const char of path9) { const code2 = char.charCodeAt(0); if (code2 < 33 || char === ";") { throw new Error("Invalid cookie path"); @@ -17211,11 +17211,11 @@ var require_undici = __commonJS({ if (typeof opts.path !== "string") { throw new InvalidArgumentError("invalid opts.path"); } - let path10 = opts.path; + let path9 = opts.path; if (!opts.path.startsWith("/")) { - path10 = `/${path10}`; + path9 = `/${path9}`; } - url = new URL(util.parseOrigin(url).origin + path10); + url = new URL(util.parseOrigin(url).origin + path9); } else { if (!opts) { opts = typeof url === "object" ? url : {}; @@ -18438,7 +18438,7 @@ var require_path_utils = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.toPlatformPath = exports2.toWin32Path = exports2.toPosixPath = void 0; - var path10 = __importStar(require("path")); + var path9 = __importStar(require("path")); function toPosixPath(pth) { return pth.replace(/[\\]/g, "/"); } @@ -18448,7 +18448,7 @@ var require_path_utils = __commonJS({ } exports2.toWin32Path = toWin32Path; function toPlatformPath(pth) { - return pth.replace(/[/\\]/g, path10.sep); + return pth.replace(/[/\\]/g, path9.sep); } exports2.toPlatformPath = toPlatformPath; } @@ -18512,7 +18512,7 @@ var require_io_util = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getCmdPath = exports2.tryGetExecutablePath = exports2.isRooted = exports2.isDirectory = exports2.exists = exports2.READONLY = exports2.UV_FS_O_EXLOCK = exports2.IS_WINDOWS = exports2.unlink = exports2.symlink = exports2.stat = exports2.rmdir = exports2.rm = exports2.rename = exports2.readlink = exports2.readdir = exports2.open = exports2.mkdir = exports2.lstat = exports2.copyFile = exports2.chmod = void 0; var fs15 = __importStar(require("fs")); - var path10 = __importStar(require("path")); + var path9 = __importStar(require("path")); _a = fs15.promises, exports2.chmod = _a.chmod, exports2.copyFile = _a.copyFile, exports2.lstat = _a.lstat, exports2.mkdir = _a.mkdir, exports2.open = _a.open, exports2.readdir = _a.readdir, exports2.readlink = _a.readlink, exports2.rename = _a.rename, exports2.rm = _a.rm, exports2.rmdir = _a.rmdir, exports2.stat = _a.stat, exports2.symlink = _a.symlink, exports2.unlink = _a.unlink; exports2.IS_WINDOWS = process.platform === "win32"; exports2.UV_FS_O_EXLOCK = 268435456; @@ -18561,7 +18561,7 @@ var require_io_util = __commonJS({ } if (stats && stats.isFile()) { if (exports2.IS_WINDOWS) { - const upperExt = path10.extname(filePath).toUpperCase(); + const upperExt = path9.extname(filePath).toUpperCase(); if (extensions.some((validExt) => validExt.toUpperCase() === upperExt)) { return filePath; } @@ -18585,11 +18585,11 @@ var require_io_util = __commonJS({ if (stats && stats.isFile()) { if (exports2.IS_WINDOWS) { try { - const directory = path10.dirname(filePath); - const upperName = path10.basename(filePath).toUpperCase(); + const directory = path9.dirname(filePath); + const upperName = path9.basename(filePath).toUpperCase(); for (const actualName of yield exports2.readdir(directory)) { if (upperName === actualName.toUpperCase()) { - filePath = path10.join(directory, actualName); + filePath = path9.join(directory, actualName); break; } } @@ -18684,7 +18684,7 @@ var require_io = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.findInPath = exports2.which = exports2.mkdirP = exports2.rmRF = exports2.mv = exports2.cp = void 0; var assert_1 = require("assert"); - var path10 = __importStar(require("path")); + var path9 = __importStar(require("path")); var ioUtil = __importStar(require_io_util()); function cp(source, dest, options = {}) { return __awaiter(this, void 0, void 0, function* () { @@ -18693,7 +18693,7 @@ var require_io = __commonJS({ if (destStat && destStat.isFile() && !force) { return; } - const newDest = destStat && destStat.isDirectory() && copySourceDirectory ? path10.join(dest, path10.basename(source)) : dest; + const newDest = destStat && destStat.isDirectory() && copySourceDirectory ? path9.join(dest, path9.basename(source)) : dest; if (!(yield ioUtil.exists(source))) { throw new Error(`no such file or directory: ${source}`); } @@ -18705,7 +18705,7 @@ var require_io = __commonJS({ yield cpDirRecursive(source, newDest, 0, force); } } else { - if (path10.relative(source, newDest) === "") { + if (path9.relative(source, newDest) === "") { throw new Error(`'${newDest}' and '${source}' are the same file`); } yield copyFile(source, newDest, force); @@ -18718,7 +18718,7 @@ var require_io = __commonJS({ if (yield ioUtil.exists(dest)) { let destExists = true; if (yield ioUtil.isDirectory(dest)) { - dest = path10.join(dest, path10.basename(source)); + dest = path9.join(dest, path9.basename(source)); destExists = yield ioUtil.exists(dest); } if (destExists) { @@ -18729,7 +18729,7 @@ var require_io = __commonJS({ } } } - yield mkdirP(path10.dirname(dest)); + yield mkdirP(path9.dirname(dest)); yield ioUtil.rename(source, dest); }); } @@ -18792,7 +18792,7 @@ var require_io = __commonJS({ } const extensions = []; if (ioUtil.IS_WINDOWS && process.env["PATHEXT"]) { - for (const extension of process.env["PATHEXT"].split(path10.delimiter)) { + for (const extension of process.env["PATHEXT"].split(path9.delimiter)) { if (extension) { extensions.push(extension); } @@ -18805,12 +18805,12 @@ var require_io = __commonJS({ } return []; } - if (tool.includes(path10.sep)) { + if (tool.includes(path9.sep)) { return []; } const directories = []; if (process.env.PATH) { - for (const p of process.env.PATH.split(path10.delimiter)) { + for (const p of process.env.PATH.split(path9.delimiter)) { if (p) { directories.push(p); } @@ -18818,7 +18818,7 @@ var require_io = __commonJS({ } const matches = []; for (const directory of directories) { - const filePath = yield ioUtil.tryGetExecutablePath(path10.join(directory, tool), extensions); + const filePath = yield ioUtil.tryGetExecutablePath(path9.join(directory, tool), extensions); if (filePath) { matches.push(filePath); } @@ -18931,10 +18931,10 @@ var require_toolrunner = __commonJS({ }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.argStringToArray = exports2.ToolRunner = void 0; - var os2 = __importStar(require("os")); + var os = __importStar(require("os")); var events = __importStar(require("events")); var child = __importStar(require("child_process")); - var path10 = __importStar(require("path")); + var path9 = __importStar(require("path")); var io = __importStar(require_io()); var ioUtil = __importStar(require_io_util()); var timers_1 = require("timers"); @@ -18986,12 +18986,12 @@ var require_toolrunner = __commonJS({ _processLineBuffer(data, strBuffer, onLine) { try { let s2 = strBuffer + data.toString(); - let n = s2.indexOf(os2.EOL); + let n = s2.indexOf(os.EOL); while (n > -1) { const line = s2.substring(0, n); onLine(line); - s2 = s2.substring(n + os2.EOL.length); - n = s2.indexOf(os2.EOL); + s2 = s2.substring(n + os.EOL.length); + n = s2.indexOf(os.EOL); } return s2; } catch (err) { @@ -19149,7 +19149,7 @@ var require_toolrunner = __commonJS({ exec() { return __awaiter(this, void 0, void 0, function* () { if (!ioUtil.isRooted(this.toolPath) && (this.toolPath.includes("/") || IS_WINDOWS && this.toolPath.includes("\\"))) { - this.toolPath = path10.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); + this.toolPath = path9.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); } this.toolPath = yield io.which(this.toolPath, true); return new Promise((resolve2, reject) => __awaiter(this, void 0, void 0, function* () { @@ -19160,7 +19160,7 @@ var require_toolrunner = __commonJS({ } const optionsNonNull = this._cloneExecOptions(this.options); if (!optionsNonNull.silent && optionsNonNull.outStream) { - optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os2.EOL); + optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL); } const state = new ExecState(optionsNonNull, this.toolPath); state.on("debug", (message) => { @@ -19648,8 +19648,8 @@ var require_core = __commonJS({ var command_1 = require_command(); var file_command_1 = require_file_command(); var utils_1 = require_utils(); - var os2 = __importStar(require("os")); - var path10 = __importStar(require("path")); + var os = __importStar(require("os")); + var path9 = __importStar(require("path")); var oidc_utils_1 = require_oidc_utils(); var ExitCode; (function(ExitCode2) { @@ -19677,10 +19677,10 @@ var require_core = __commonJS({ } else { (0, command_1.issueCommand)("add-path", {}, inputPath); } - process.env["PATH"] = `${inputPath}${path10.delimiter}${process.env["PATH"]}`; + process.env["PATH"] = `${inputPath}${path9.delimiter}${process.env["PATH"]}`; } exports2.addPath = addPath; - function getInput(name2, options) { + function getInput2(name2, options) { const val = process.env[`INPUT_${name2.replace(/ /g, "_").toUpperCase()}`] || ""; if (options && options.required && !val) { throw new Error(`Input required and not supplied: ${name2}`); @@ -19690,9 +19690,9 @@ var require_core = __commonJS({ } return val.trim(); } - exports2.getInput = getInput; + exports2.getInput = getInput2; function getMultilineInput2(name2, options) { - const inputs = getInput(name2, options).split("\n").filter((x2) => x2 !== ""); + const inputs = getInput2(name2, options).split("\n").filter((x2) => x2 !== ""); if (options && options.trimWhitespace === false) { return inputs; } @@ -19702,7 +19702,7 @@ var require_core = __commonJS({ function getBooleanInput(name2, options) { const trueValue = ["true", "True", "TRUE"]; const falseValue = ["false", "False", "FALSE"]; - const val = getInput(name2, options); + const val = getInput2(name2, options); if (trueValue.includes(val)) return true; if (falseValue.includes(val)) @@ -19716,7 +19716,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); if (filePath) { return (0, file_command_1.issueFileCommand)("OUTPUT", (0, file_command_1.prepareKeyValueMessage)(name2, value)); } - process.stdout.write(os2.EOL); + process.stdout.write(os.EOL); (0, command_1.issueCommand)("set-output", { name: name2 }, (0, utils_1.toCommandValue)(value)); } exports2.setOutput = setOutput2; @@ -19750,7 +19750,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); } exports2.notice = notice; function info4(message) { - process.stdout.write(message + os2.EOL); + process.stdout.write(message + os.EOL); } exports2.info = info4; function startGroup(name2) { @@ -24875,7 +24875,7 @@ var core3 = __toESM(require_core()); // src/save.ts var core = __toESM(require_core()); var fs13 = __toESM(require("fs")); -var path9 = __toESM(require("path")); +var path8 = __toESM(require("path")); // node_modules/@isaacs/fs-minipass/dist/esm/index.js var import_events = __toESM(require("events"), 1); @@ -25798,17 +25798,17 @@ var ReadStream = class extends Minipass { [_size]; [_remain]; [_autoClose]; - constructor(path10, opt) { + constructor(path9, opt) { opt = opt || {}; super(opt); this.readable = true; this.writable = false; - if (typeof path10 !== "string") { + if (typeof path9 !== "string") { throw new TypeError("path must be a string"); } this[_errored] = false; this[_fd] = typeof opt.fd === "number" ? opt.fd : void 0; - this[_path] = path10; + this[_path] = path9; this[_readSize] = opt.readSize || 16 * 1024 * 1024; this[_reading] = false; this[_size] = typeof opt.size === "number" ? opt.size : Infinity; @@ -25971,10 +25971,10 @@ var WriteStream = class extends import_events.default { [_flags]; [_finished] = false; [_pos]; - constructor(path10, opt) { + constructor(path9, opt) { opt = opt || {}; super(opt); - this[_path] = path10; + this[_path] = path9; this[_fd] = typeof opt.fd === "number" ? opt.fd : void 0; this[_mode] = opt.mode === void 0 ? 438 : opt.mode; this[_pos] = typeof opt.start === "number" ? opt.start : void 0; @@ -28094,10 +28094,10 @@ var Header = class { } const prefixSize = this.ctime || this.atime ? 130 : 155; const split = splitPrefix(this.path || "", prefixSize); - const path10 = split[0]; + const path9 = split[0]; const prefix = split[1]; this.needPax = !!split[2]; - this.needPax = encString(buf, off, 100, path10) || this.needPax; + this.needPax = encString(buf, off, 100, path9) || this.needPax; this.needPax = encNumber(buf, off + 100, 8, this.mode) || this.needPax; this.needPax = encNumber(buf, off + 108, 8, this.uid) || this.needPax; this.needPax = encNumber(buf, off + 116, 8, this.gid) || this.needPax; @@ -29932,16 +29932,16 @@ var modeFix = (mode, isDir, portable) => { // node_modules/tar/dist/esm/strip-absolute-path.js var import_node_path3 = require("node:path"); var { isAbsolute, parse: parse3 } = import_node_path3.win32; -var stripAbsolutePath = (path10) => { +var stripAbsolutePath = (path9) => { let r2 = ""; - let parsed = parse3(path10); - while (isAbsolute(path10) || parsed.root) { - const root = path10.charAt(0) === "/" && path10.slice(0, 4) !== "//?/" ? "/" : parsed.root; - path10 = path10.slice(root.length); + let parsed = parse3(path9); + while (isAbsolute(path9) || parsed.root) { + const root = path9.charAt(0) === "/" && path9.slice(0, 4) !== "//?/" ? "/" : parsed.root; + path9 = path9.slice(root.length); r2 += root; - parsed = parse3(path10); + parsed = parse3(path9); } - return [r2, path10]; + return [r2, path9]; }; // node_modules/tar/dist/esm/winchars.js @@ -29953,12 +29953,12 @@ var encode2 = (s2) => raw.reduce((s3, c) => s3.split(c).join(toWin.get(c)), s2); var decode = (s2) => win.reduce((s3, c) => s3.split(c).join(toRaw.get(c)), s2); // node_modules/tar/dist/esm/write-entry.js -var prefixPath = (path10, prefix) => { +var prefixPath = (path9, prefix) => { if (!prefix) { - return normalizeWindowsPath(path10); + return normalizeWindowsPath(path9); } - path10 = normalizeWindowsPath(path10).replace(/^\.(\/|$)/, ""); - return stripTrailingSlashes(prefix) + "/" + path10; + path9 = normalizeWindowsPath(path9).replace(/^\.(\/|$)/, ""); + return stripTrailingSlashes(prefix) + "/" + path9; }; var maxReadSize = 16 * 1024 * 1024; var PROCESS = Symbol("process"); @@ -30103,8 +30103,8 @@ var WriteEntry = class extends Minipass3 { [MODE](mode) { return modeFix(mode, this.type === "Directory", this.portable); } - [PREFIX](path10) { - return prefixPath(path10, this.prefix); + [PREFIX](path9) { + return prefixPath(path9, this.prefix); } [HEADER]() { if (!this.stat) { @@ -30485,8 +30485,8 @@ var WriteEntryTar = class extends Minipass3 { super.write(b); readEntry.pipe(this); } - [PREFIX](path10) { - return prefixPath(path10, this.prefix); + [PREFIX](path9) { + return prefixPath(path9, this.prefix); } [MODE](mode) { return modeFix(mode, this.type === "Directory", this.portable); @@ -30541,8 +30541,8 @@ var PackJob = class { pending = false; ignore = false; piped = false; - constructor(path10, absolute) { - this.path = path10 || "./"; + constructor(path9, absolute) { + this.path = path9 || "./"; this.absolute = absolute; } }; @@ -30656,21 +30656,21 @@ var Pack = class extends Minipass3 { [WRITE](chunk) { return super.write(chunk); } - add(path10) { - this.write(path10); + add(path9) { + this.write(path9); return this; } - end(path10, encoding, cb) { - if (typeof path10 === "function") { - cb = path10; - path10 = void 0; + end(path9, encoding, cb) { + if (typeof path9 === "function") { + cb = path9; + path9 = void 0; } if (typeof encoding === "function") { cb = encoding; encoding = void 0; } - if (path10) { - this.add(path10); + if (path9) { + this.add(path9); } this[ENDED2] = true; this[PROCESS2](); @@ -30678,14 +30678,14 @@ var Pack = class extends Minipass3 { cb(); return this; } - write(path10) { + write(path9) { if (this[ENDED2]) { throw new Error("write after end"); } - if (path10 instanceof ReadEntry) { - this[ADDTARENTRY](path10); + if (path9 instanceof ReadEntry) { + this[ADDTARENTRY](path9); } else { - this[ADDFSENTRY](path10); + this[ADDFSENTRY](path9); } return this.flowing; } @@ -31028,9 +31028,9 @@ var getWriteFlag = !fMapEnabled ? () => "w" : (size) => size < fMapLimit ? fMapF // node_modules/chownr/dist/esm/index.js var import_node_fs2 = __toESM(require("node:fs"), 1); var import_node_path5 = __toESM(require("node:path"), 1); -var lchownSync = (path10, uid, gid) => { +var lchownSync = (path9, uid, gid) => { try { - return import_node_fs2.default.lchownSync(path10, uid, gid); + return import_node_fs2.default.lchownSync(path9, uid, gid); } catch (er) { if (er?.code !== "ENOENT") throw er; @@ -31126,23 +31126,23 @@ var optsArg = (opts) => { const resolved = opts; const optsFs = opts.fs || {}; opts.mkdir = opts.mkdir || optsFs.mkdir || import_fs5.mkdir; - opts.mkdirAsync = opts.mkdirAsync ? opts.mkdirAsync : async (path10, options) => { - return new Promise((res, rej) => resolved.mkdir(path10, options, (er, made) => er ? rej(er) : res(made))); + opts.mkdirAsync = opts.mkdirAsync ? opts.mkdirAsync : async (path9, options) => { + return new Promise((res, rej) => resolved.mkdir(path9, options, (er, made) => er ? rej(er) : res(made))); }; opts.stat = opts.stat || optsFs.stat || import_fs5.stat; - opts.statAsync = opts.statAsync ? opts.statAsync : async (path10) => new Promise((res, rej) => resolved.stat(path10, (err, stats) => err ? rej(err) : res(stats))); + opts.statAsync = opts.statAsync ? opts.statAsync : async (path9) => new Promise((res, rej) => resolved.stat(path9, (err, stats) => err ? rej(err) : res(stats))); opts.statSync = opts.statSync || optsFs.statSync || import_fs5.statSync; opts.mkdirSync = opts.mkdirSync || optsFs.mkdirSync || import_fs5.mkdirSync; return resolved; }; // node_modules/mkdirp/dist/mjs/mkdirp-manual.js -var mkdirpManualSync = (path10, options, made) => { - const parent = (0, import_path4.dirname)(path10); +var mkdirpManualSync = (path9, options, made) => { + const parent = (0, import_path4.dirname)(path9); const opts = { ...optsArg(options), recursive: false }; - if (parent === path10) { + if (parent === path9) { try { - return opts.mkdirSync(path10, opts); + return opts.mkdirSync(path9, opts); } catch (er) { const fer = er; if (fer && fer.code !== "EISDIR") { @@ -31152,45 +31152,45 @@ var mkdirpManualSync = (path10, options, made) => { } } try { - opts.mkdirSync(path10, opts); - return made || path10; + opts.mkdirSync(path9, opts); + return made || path9; } catch (er) { const fer = er; if (fer && fer.code === "ENOENT") { - return mkdirpManualSync(path10, opts, mkdirpManualSync(parent, opts, made)); + return mkdirpManualSync(path9, opts, mkdirpManualSync(parent, opts, made)); } if (fer && fer.code !== "EEXIST" && fer && fer.code !== "EROFS") { throw er; } try { - if (!opts.statSync(path10).isDirectory()) + if (!opts.statSync(path9).isDirectory()) throw er; } catch (_) { throw er; } } }; -var mkdirpManual = Object.assign(async (path10, options, made) => { +var mkdirpManual = Object.assign(async (path9, options, made) => { const opts = optsArg(options); opts.recursive = false; - const parent = (0, import_path4.dirname)(path10); - if (parent === path10) { - return opts.mkdirAsync(path10, opts).catch((er) => { + const parent = (0, import_path4.dirname)(path9); + if (parent === path9) { + return opts.mkdirAsync(path9, opts).catch((er) => { const fer = er; if (fer && fer.code !== "EISDIR") { throw er; } }); } - return opts.mkdirAsync(path10, opts).then(() => made || path10, async (er) => { + return opts.mkdirAsync(path9, opts).then(() => made || path9, async (er) => { const fer = er; if (fer && fer.code === "ENOENT") { - return mkdirpManual(parent, opts).then((made2) => mkdirpManual(path10, opts, made2)); + return mkdirpManual(parent, opts).then((made2) => mkdirpManual(path9, opts, made2)); } if (fer && fer.code !== "EEXIST" && fer.code !== "EROFS") { throw er; } - return opts.statAsync(path10).then((st) => { + return opts.statAsync(path9).then((st) => { if (st.isDirectory()) { return made; } else { @@ -31207,12 +31207,12 @@ var import_path6 = require("path"); // node_modules/mkdirp/dist/mjs/find-made.js var import_path5 = require("path"); -var findMade = async (opts, parent, path10) => { - if (path10 === parent) { +var findMade = async (opts, parent, path9) => { + if (path9 === parent) { return; } return opts.statAsync(parent).then( - (st) => st.isDirectory() ? path10 : void 0, + (st) => st.isDirectory() ? path9 : void 0, // will fail later // will fail later (er) => { @@ -31221,12 +31221,12 @@ var findMade = async (opts, parent, path10) => { } ); }; -var findMadeSync = (opts, parent, path10) => { - if (path10 === parent) { +var findMadeSync = (opts, parent, path9) => { + if (path9 === parent) { return void 0; } try { - return opts.statSync(parent).isDirectory() ? path10 : void 0; + return opts.statSync(parent).isDirectory() ? path9 : void 0; } catch (er) { const fer = er; return fer && fer.code === "ENOENT" ? findMadeSync(opts, (0, import_path5.dirname)(parent), parent) : void 0; @@ -31234,36 +31234,36 @@ var findMadeSync = (opts, parent, path10) => { }; // node_modules/mkdirp/dist/mjs/mkdirp-native.js -var mkdirpNativeSync = (path10, options) => { +var mkdirpNativeSync = (path9, options) => { const opts = optsArg(options); opts.recursive = true; - const parent = (0, import_path6.dirname)(path10); - if (parent === path10) { - return opts.mkdirSync(path10, opts); + const parent = (0, import_path6.dirname)(path9); + if (parent === path9) { + return opts.mkdirSync(path9, opts); } - const made = findMadeSync(opts, path10); + const made = findMadeSync(opts, path9); try { - opts.mkdirSync(path10, opts); + opts.mkdirSync(path9, opts); return made; } catch (er) { const fer = er; if (fer && fer.code === "ENOENT") { - return mkdirpManualSync(path10, opts); + return mkdirpManualSync(path9, opts); } else { throw er; } } }; -var mkdirpNative = Object.assign(async (path10, options) => { +var mkdirpNative = Object.assign(async (path9, options) => { const opts = { ...optsArg(options), recursive: true }; - const parent = (0, import_path6.dirname)(path10); - if (parent === path10) { - return await opts.mkdirAsync(path10, opts); + const parent = (0, import_path6.dirname)(path9); + if (parent === path9) { + return await opts.mkdirAsync(path9, opts); } - return findMade(opts, path10).then((made) => opts.mkdirAsync(path10, opts).then((m2) => made || m2).catch((er) => { + return findMade(opts, path9).then((made) => opts.mkdirAsync(path9, opts).then((m2) => made || m2).catch((er) => { const fer = er; if (fer && fer.code === "ENOENT") { - return mkdirpManual(path10, opts); + return mkdirpManual(path9, opts); } else { throw er; } @@ -31273,25 +31273,25 @@ var mkdirpNative = Object.assign(async (path10, options) => { // node_modules/mkdirp/dist/mjs/path-arg.js var import_path7 = require("path"); var platform3 = process.env.__TESTING_MKDIRP_PLATFORM__ || process.platform; -var pathArg = (path10) => { - if (/\0/.test(path10)) { +var pathArg = (path9) => { + if (/\0/.test(path9)) { throw Object.assign(new TypeError("path must be a string without null bytes"), { - path: path10, + path: path9, code: "ERR_INVALID_ARG_VALUE" }); } - path10 = (0, import_path7.resolve)(path10); + path9 = (0, import_path7.resolve)(path9); if (platform3 === "win32") { const badWinChars = /[*|"<>?:]/; - const { root } = (0, import_path7.parse)(path10); - if (badWinChars.test(path10.substring(root.length))) { + const { root } = (0, import_path7.parse)(path9); + if (badWinChars.test(path9.substring(root.length))) { throw Object.assign(new Error("Illegal characters in path."), { - path: path10, + path: path9, code: "EINVAL" }); } } - return path10; + return path9; }; // node_modules/mkdirp/dist/mjs/use-native.js @@ -31305,15 +31305,15 @@ var useNative = Object.assign(!hasNative ? () => false : (opts) => optsArg(opts) }); // node_modules/mkdirp/dist/mjs/index.js -var mkdirpSync = (path10, opts) => { - path10 = pathArg(path10); +var mkdirpSync = (path9, opts) => { + path9 = pathArg(path9); const resolved = optsArg(opts); - return useNativeSync(resolved) ? mkdirpNativeSync(path10, resolved) : mkdirpManualSync(path10, resolved); + return useNativeSync(resolved) ? mkdirpNativeSync(path9, resolved) : mkdirpManualSync(path9, resolved); }; -var mkdirp = Object.assign(async (path10, opts) => { - path10 = pathArg(path10); +var mkdirp = Object.assign(async (path9, opts) => { + path9 = pathArg(path9); const resolved = optsArg(opts); - return useNative(resolved) ? mkdirpNative(path10, resolved) : mkdirpManual(path10, resolved); + return useNative(resolved) ? mkdirpNative(path9, resolved) : mkdirpManual(path9, resolved); }, { mkdirpSync, mkdirpNative, @@ -31337,9 +31337,9 @@ var CwdError = class extends Error { path; code; syscall = "chdir"; - constructor(path10, code2) { - super(`${code2}: Cannot cd into '${path10}'`); - this.path = path10; + constructor(path9, code2) { + super(`${code2}: Cannot cd into '${path9}'`); + this.path = path9; this.code = code2; } get name() { @@ -31353,10 +31353,10 @@ var SymlinkError = class extends Error { symlink; syscall = "symlink"; code = "TAR_SYMLINK_ERROR"; - constructor(symlink, path10) { + constructor(symlink, path9) { super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"); this.symlink = symlink; - this.path = path10; + this.path = path9; } get name() { return "SymlinkError"; @@ -31543,13 +31543,13 @@ var normalizeUnicode = (s2) => { var import_node_path7 = require("node:path"); var platform4 = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform; var isWindows2 = platform4 === "win32"; -var getDirs = (path10) => { - const dirs = path10.split("/").slice(0, -1).reduce((set, path11) => { +var getDirs = (path9) => { + const dirs = path9.split("/").slice(0, -1).reduce((set, path10) => { const s2 = set[set.length - 1]; if (s2 !== void 0) { - path11 = (0, import_node_path7.join)(s2, path11); + path10 = (0, import_node_path7.join)(s2, path10); } - set.push(path11 || "/"); + set.push(path10 || "/"); return set; }, []); return dirs; @@ -31567,7 +31567,7 @@ var PathReservations = class { paths = isWindows2 ? ["win32 parallelization disabled"] : paths.map((p) => { return stripTrailingSlashes((0, import_node_path7.join)(normalizeUnicode(p))).toLowerCase(); }); - const dirs = new Set(paths.map((path10) => getDirs(path10)).reduce((a, b) => a.concat(b))); + const dirs = new Set(paths.map((path9) => getDirs(path9)).reduce((a, b) => a.concat(b))); this.#reservations.set(fn, { dirs, paths }); for (const p of paths) { const q = this.#queues.get(p); @@ -31600,8 +31600,8 @@ var PathReservations = class { throw new Error("function does not have any path reservations"); } return { - paths: res.paths.map((path10) => this.#queues.get(path10)), - dirs: [...res.dirs].map((path10) => this.#queues.get(path10)) + paths: res.paths.map((path9) => this.#queues.get(path9)), + dirs: [...res.dirs].map((path9) => this.#queues.get(path9)) }; } // check if fn is first in line for all its paths, and is @@ -31629,14 +31629,14 @@ var PathReservations = class { } const { paths, dirs } = res; const next = /* @__PURE__ */ new Set(); - for (const path10 of paths) { - const q = this.#queues.get(path10); + for (const path9 of paths) { + const q = this.#queues.get(path9); if (!q || q?.[0] !== fn) { continue; } const q0 = q[1]; if (!q0) { - this.#queues.delete(path10); + this.#queues.delete(path9); continue; } q.shift(); @@ -31701,34 +31701,34 @@ var CHECKED_CWD = Symbol("checkedCwd"); var platform5 = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform; var isWindows3 = platform5 === "win32"; var DEFAULT_MAX_DEPTH = 1024; -var unlinkFile = (path10, cb) => { +var unlinkFile = (path9, cb) => { if (!isWindows3) { - return import_node_fs3.default.unlink(path10, cb); + return import_node_fs3.default.unlink(path9, cb); } - const name2 = path10 + ".DELETE." + (0, import_node_crypto.randomBytes)(16).toString("hex"); - import_node_fs3.default.rename(path10, name2, (er) => { + const name2 = path9 + ".DELETE." + (0, import_node_crypto.randomBytes)(16).toString("hex"); + import_node_fs3.default.rename(path9, name2, (er) => { if (er) { return cb(er); } import_node_fs3.default.unlink(name2, cb); }); }; -var unlinkFileSync = (path10) => { +var unlinkFileSync = (path9) => { if (!isWindows3) { - return import_node_fs3.default.unlinkSync(path10); + return import_node_fs3.default.unlinkSync(path9); } - const name2 = path10 + ".DELETE." + (0, import_node_crypto.randomBytes)(16).toString("hex"); - import_node_fs3.default.renameSync(path10, name2); + const name2 = path9 + ".DELETE." + (0, import_node_crypto.randomBytes)(16).toString("hex"); + import_node_fs3.default.renameSync(path9, name2); import_node_fs3.default.unlinkSync(name2); }; var uint32 = (a, b, c) => a !== void 0 && a === a >>> 0 ? a : b !== void 0 && b === b >>> 0 ? b : c; -var cacheKeyNormalize = (path10) => stripTrailingSlashes(normalizeWindowsPath(normalizeUnicode(path10))).toLowerCase(); +var cacheKeyNormalize = (path9) => stripTrailingSlashes(normalizeWindowsPath(normalizeUnicode(path9))).toLowerCase(); var pruneCache = (cache, abs) => { abs = cacheKeyNormalize(abs); - for (const path10 of cache.keys()) { - const pnorm = cacheKeyNormalize(path10); + for (const path9 of cache.keys()) { + const pnorm = cacheKeyNormalize(path9); if (pnorm === abs || pnorm.indexOf(abs + "/") === 0) { - cache.delete(path10); + cache.delete(path9); } } }; @@ -32619,9 +32619,9 @@ var mtimeFilter = (opt) => { if (!opt.mtimeCache) { opt.mtimeCache = /* @__PURE__ */ new Map(); } - opt.filter = filter ? (path10, stat3) => filter(path10, stat3) && !/* c8 ignore start */ - ((opt.mtimeCache?.get(path10) ?? stat3.mtime ?? 0) > (stat3.mtime ?? 0)) : (path10, stat3) => !/* c8 ignore start */ - ((opt.mtimeCache?.get(path10) ?? stat3.mtime ?? 0) > (stat3.mtime ?? 0)); + opt.filter = filter ? (path9, stat3) => filter(path9, stat3) && !/* c8 ignore start */ + ((opt.mtimeCache?.get(path9) ?? stat3.mtime ?? 0) > (stat3.mtime ?? 0)) : (path9, stat3) => !/* c8 ignore start */ + ((opt.mtimeCache?.get(path9) ?? stat3.mtime ?? 0) > (stat3.mtime ?? 0)); }; // src/save.ts @@ -33983,8 +33983,6 @@ async function downloadCache(options, owner, repo, key, destinationPath) { } // src/util.ts -var import_path8 = __toESM(require("path")); -var os = __toESM(require("os")); function formatSize(bytes) { if (bytes >= 1e9) { return `${(bytes / 1e9).toFixed(2)} GB`; @@ -33994,22 +33992,15 @@ function formatSize(bytes) { return `${(bytes / 1e3).toFixed(2)} KB`; } } -function expandPath(p) { - if (p.startsWith("~")) { - return import_path8.default.join(os.homedir(), p.slice(1)); - } - return p; -} // src/save.ts var execFileAsync = (0, import_util.promisify)(import_child_process.execFile); async function saveCache(key, paths) { const tempDir = await fs13.promises.mkdtemp("/tmp/cache-save-"); - const tarPath = path9.join(tempDir, "cache.tar"); - const zstPath = path9.join(tempDir, "cache.tar.zst"); + const tarPath = path8.join(tempDir, "cache.tar"); + const zstPath = path8.join(tempDir, "cache.tar.zst"); let startTime = Date.now(); core.info(`Creating tar archive: ${tarPath}`); - const expandedPaths = paths.map(expandPath); await create( { file: tarPath, @@ -34018,7 +34009,7 @@ async function saveCache(key, paths) { gzip: false // No gzip compression }, - expandedPaths + paths ); const tarSize = fs13.statSync(tarPath).size; let endTime = Date.now(); @@ -34062,41 +34053,51 @@ var fs14 = __toESM(require("fs")); var import_child_process2 = require("child_process"); var import_util3 = require("util"); var execFileAsync2 = (0, import_util3.promisify)(import_child_process2.execFile); -async function restoreCache(keys) { +async function restoreCache(key) { + const zstPath = `/tmp/${key}.tar.zst`; + const tarPath = `/tmp/${key}.tar`; + core2.info(`Downloading cache for key ${key}...`); + let startTime = Date.now(); const { owner, repo } = getRepoInfo(); - const serverUrl = getServerUrl(); - const token = getToken(); - for (const key of keys) { - const zstPath = `/tmp/${key}.tar.zst`; - const tarPath = `/tmp/${key}.tar`; - core2.info(`\u{1F50D} Probiere Cache-Key: ${key}`); - const downloaded = await downloadCache( - { serverUrl, token }, - owner, - repo, - key, - zstPath - ); - if (!downloaded) { - core2.info(`\u274C Kein Treffer f\xFCr: ${key}`); - continue; - } - const zstSize = fs14.statSync(zstPath).size; - core2.info(`\u2705 Gefunden: ${key} (${formatSize(zstSize)})`); - core2.info("\u{1F4E6} Entpacke Zstandard-Archiv..."); - const startDecompress = Date.now(); - await execFileAsync2("zstd", ["-d", "-o", tarPath, zstPath]); - const decompressTime = ((Date.now() - startDecompress) / 1e3).toFixed(2); - const tarSize = fs14.statSync(tarPath).size; - core2.info(`\u{1F4C2} Extrahiere Tar (${formatSize(tarSize)})...`); - const startExtract = Date.now(); - await execFileAsync2("tar", ["-xf", tarPath, "-C", "/"]); - const extractTime = ((Date.now() - startExtract) / 1e3).toFixed(2); - core2.info(`\u2705 Wiederhergestellt in ${decompressTime}s + ${extractTime}s`); - return key; + const downloaded = await downloadCache( + { serverUrl: getServerUrl(), token: getToken() }, + owner, + repo, + key, + zstPath + ); + if (!downloaded) { + core2.warning("Cache archive not found, skipping restore."); + return false; } - core2.warning("\u{1F7E1} Kein Cache gefunden."); - return null; + let endTime = Date.now(); + let duration = endTime - startTime; + let durationInSeconds = (duration / 1e3).toFixed(2); + const zstSize = fs14.statSync(zstPath).size; + core2.info( + `Download completed in ${durationInSeconds} seconds (${formatSize(zstSize)})` + ); + core2.info("Decompressing zstd archive..."); + startTime = Date.now(); + await execFileAsync2("zstd", ["-d", "-o", tarPath, zstPath]); + endTime = Date.now(); + duration = endTime - startTime; + durationInSeconds = (duration / 1e3).toFixed(2); + const tarSize = fs14.statSync(tarPath).size; + core2.info( + `Decompression completed in ${durationInSeconds} seconds (${formatSize(zstSize)} -> ${formatSize(tarSize)})` + ); + core2.info("Extracting tar archive with system tar..."); + startTime = Date.now(); + await execFileAsync2("tar", ["-xf", tarPath, "-C", "/"]); + endTime = Date.now(); + duration = endTime - startTime; + durationInSeconds = (duration / 1e3).toFixed(2); + core2.info( + `Extraction completed in ${durationInSeconds} seconds (${formatSize(tarSize)})` + ); + core2.info("Cache successfully restored!"); + return true; } // src/index.ts @@ -34104,37 +34105,33 @@ async function run() { try { if (core3.getState("isPost") === "true") { core3.info("Post-job: Saving cache..."); - const keys = JSON.parse(core3.getState("keys") || "[]"); - const key = keys[0]; + const key = core3.getState("key"); const paths = JSON.parse(core3.getState("paths") || "[]"); - if (!key) throw new Error("State 'key' not found during Post-Job."); - if (paths.length === 0) { - throw new Error("State 'paths' is empty during Post-Job."); + if (!key) { + throw new Error("State 'key' not found during Post-Job."); + } + if (paths.length === 0) { + throw new Error("State 'paths' not found or empty during Post-Job."); } - core3.info(`Saving cache using primary key: ${key}`); await saveCache(key, paths); } else { core3.info("Pre-job: Restoring cache..."); - const keys = core3.getMultilineInput("keys", { required: true }).filter( - Boolean - ); + const key = core3.getInput("key", { required: true }); const paths = core3.getMultilineInput("paths", { required: true }).filter( - Boolean + (p) => p.trim() !== "" ); - if (keys.length === 0) { - throw new Error("At least one cache key must be provided."); - } core3.saveState("isPost", "true"); - core3.saveState("keys", JSON.stringify(keys)); + core3.saveState("key", key); core3.saveState("paths", JSON.stringify(paths)); - const restoredKey = await restoreCache(keys); - core3.setOutput("cache-hit", restoredKey ? "true" : "false"); - if (restoredKey) { - core3.setOutput("restored-key", restoredKey); - } + const restored = await restoreCache(key); + core3.setOutput("cache-hit", restored ? "true" : "false"); } } catch (error) { - core3.setFailed(error instanceof Error ? error.message : String(error)); + if (error instanceof Error) { + core3.setFailed(error.message); + } else { + core3.setFailed(String(error)); + } } } run();