mirror of
https://github.com/github/codeql-action.git
synced 2026-10-30 17:39:50 +00:00
Refactor cache file reading to check for existence before attempting to read
This commit is contained in:
6
lib/entry-points.js
generated
6
lib/entry-points.js
generated
@@ -149876,13 +149876,11 @@ function getCommandCacheFilePath() {
|
||||
return path6.join(getTemporaryDirectory(), COMMAND_CACHE_FILENAME);
|
||||
}
|
||||
function readCommandCacheFile() {
|
||||
let contents;
|
||||
try {
|
||||
contents = fs6.readFileSync(getCommandCacheFilePath(), "utf8");
|
||||
} catch {
|
||||
if (!fs6.existsSync(getCommandCacheFilePath())) {
|
||||
return {};
|
||||
}
|
||||
try {
|
||||
const contents = fs6.readFileSync(getCommandCacheFilePath(), "utf8");
|
||||
const parsed = parseString(contents);
|
||||
if (isObject(parsed)) {
|
||||
return parsed;
|
||||
|
||||
@@ -47,13 +47,11 @@ function getCommandCacheFilePath(): string {
|
||||
* or otherwise unreadable file is treated as an empty cache.
|
||||
*/
|
||||
function readCommandCacheFile(): Record<string, CommandCacheEntry> {
|
||||
let contents: string;
|
||||
try {
|
||||
contents = fs.readFileSync(getCommandCacheFilePath(), "utf8");
|
||||
} catch {
|
||||
if (!fs.existsSync(getCommandCacheFilePath())) {
|
||||
return {};
|
||||
}
|
||||
try {
|
||||
const contents = fs.readFileSync(getCommandCacheFilePath(), "utf8");
|
||||
const parsed = json.parseString(contents);
|
||||
if (json.isObject(parsed)) {
|
||||
return parsed;
|
||||
|
||||
Reference in New Issue
Block a user