mirror of
https://github.com/github/codeql-action.git
synced 2026-10-29 17:17:15 +00:00
Add logging for command cache file read/write failures
This commit is contained in:
2283
lib/entry-points.js
generated
2283
lib/entry-points.js
generated
File diff suppressed because it is too large
Load Diff
10
src/cache.ts
10
src/cache.ts
@@ -3,6 +3,7 @@ import * as path from "path";
|
||||
|
||||
import { getTemporaryDirectory } from "./actions-util";
|
||||
import * as json from "./json";
|
||||
import { getActionsLogger } from "./logging";
|
||||
|
||||
/**
|
||||
* The name of the temporary file that backs the on-disk cache of
|
||||
@@ -37,6 +38,7 @@ interface CommandCacheEntry {
|
||||
* (tier 3).
|
||||
*/
|
||||
const inMemoryCache = new Map<CommandCacheKey, CommandCacheEntry>();
|
||||
const logger = getActionsLogger();
|
||||
|
||||
function getCommandCacheFilePath(): string {
|
||||
return path.join(getTemporaryDirectory(), COMMAND_CACHE_FILENAME);
|
||||
@@ -56,8 +58,8 @@ function readCommandCacheFile(): Record<string, CommandCacheEntry> {
|
||||
if (json.isObject(parsed)) {
|
||||
return parsed;
|
||||
}
|
||||
} catch {
|
||||
// Fall through and treat a malformed file as empty.
|
||||
} catch (e) {
|
||||
logger.warning(`Failed to read or parse command cache file: ${e}`);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -69,8 +71,8 @@ function readCommandCacheFile(): Record<string, CommandCacheEntry> {
|
||||
function writeCommandCacheFile(data: Record<string, CommandCacheEntry>): void {
|
||||
try {
|
||||
fs.writeFileSync(getCommandCacheFilePath(), JSON.stringify(data));
|
||||
} catch {
|
||||
// Best-effort; ignore write failures.
|
||||
} catch (e) {
|
||||
logger.warning(`Failed to write command cache file: ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user