mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 09:14:58 +00:00
Handle file-read errors as cache misses
This is particularly important for the first time that `getCachedCodeQlVersion` is invoked, as this cache file will not yet exist.
This commit is contained in:
20
lib/entry-points.js
generated
20
lib/entry-points.js
generated
@@ -145250,22 +145250,28 @@ function isPersistedVersionInfo(x) {
|
||||
const candidate = x;
|
||||
return typeof candidate === "object" && candidate !== null && typeof candidate.cmd === "string" && isVersionInfo(candidate.version);
|
||||
}
|
||||
function cacheCodeQlVersion(cmd, version) {
|
||||
function getPathToCodeQLVersionCacheFile(env) {
|
||||
return path.join(getTemporaryDirectory(env), "version.json");
|
||||
}
|
||||
function cacheCodeQlVersion(cmd, version, env = getEnv()) {
|
||||
if (cachedCodeQlVersion !== void 0) {
|
||||
throw new Error("cacheCodeQlVersion() should be called only once");
|
||||
}
|
||||
cachedCodeQlVersion = version;
|
||||
core2.exportVariable(
|
||||
"CODEQL_ACTION_CLI_VERSION_INFO" /* CODEQL_VERSION_INFO */,
|
||||
JSON.stringify({ cmd, version })
|
||||
fs.writeFileSync(
|
||||
getPathToCodeQLVersionCacheFile(env),
|
||||
JSON.stringify({ cmd, version }),
|
||||
"utf8"
|
||||
);
|
||||
}
|
||||
function getCachedCodeQlVersion(cmd) {
|
||||
function getCachedCodeQlVersion(cmd, env = getEnv()) {
|
||||
if (cachedCodeQlVersion !== void 0) {
|
||||
return cachedCodeQlVersion;
|
||||
}
|
||||
const serialized = process.env["CODEQL_ACTION_CLI_VERSION_INFO" /* CODEQL_VERSION_INFO */];
|
||||
if (!serialized) {
|
||||
let serialized;
|
||||
try {
|
||||
serialized = fs.readFileSync(getPathToCodeQLVersionCacheFile(env), "utf8");
|
||||
} catch {
|
||||
return void 0;
|
||||
}
|
||||
let persisted;
|
||||
|
||||
Reference in New Issue
Block a user