Skip to content

Commit 65392d2

Browse files
committed
Delete CLI output-cache file during init
1 parent c2fd8f5 commit 65392d2

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

lib/entry-points.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli/output-cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function resetCachedCodeQlVersion(): void {
4343
* Returns the path to the temporary file that backs the
4444
* on-disk cache of CLI responses between workflow steps.
4545
*/
46-
function getCommandCacheFilePath(env: Env): string {
46+
export function getCommandCacheFilePath(env: Env): string {
4747
return path.join(getTemporaryDirectory(env), COMMAND_CACHE_FILENAME);
4848
}
4949

src/init-action.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
getTotalCacheSize,
2323
shouldRestoreCache,
2424
} from "./caching-utils";
25+
import { getCommandCacheFilePath } from "./cli/output-cache";
2526
import { CodeQL } from "./codeql";
2627
import { getConfigFileInput } from "./config/file";
2728
import { ComputedInput, getToolsInput } from "./config/inputs";
@@ -296,6 +297,18 @@ async function run(
296297
);
297298
}
298299

300+
// Delete the CLI output-cache file if it exists, to avoid
301+
// accidentally reusing a stale version from a previous run.
302+
try {
303+
fs.unlinkSync(getCommandCacheFilePath(actionState.env));
304+
} catch (e: any) {
305+
if (e?.code !== "ENOENT") {
306+
logger.warning(
307+
`Cannot delete CLI-cache file ${getCommandCacheFilePath(actionState.env)}: ${e}`,
308+
);
309+
}
310+
}
311+
299312
// Get the computed `tools` input.
300313
toolsInput = await getToolsInput(
301314
actionStateWithFeatures,

0 commit comments

Comments
 (0)