From 4f73d1add86c1594c618b23d299266a8c96b616b Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Wed, 7 Oct 2026 18:15:22 +0100 Subject: [PATCH] Include primary cache keys as restore key --- lib/entry-points.js | 6 ++++-- src/dependency-caching.ts | 1 + src/overlay/caching.ts | 2 +- src/overlay/status.ts | 2 +- src/trap-caching.ts | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index 93084ea9be..6c4e6c20d6 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -174029,7 +174029,7 @@ async function getOverlayStatus(codeql, languages, diskUsage, logger2) { await fs8.promises.mkdir(path9.dirname(statusFile), { recursive: true }); const foundKey = await waitForResultWithTimeLimit( MAX_CACHE_OPERATION_MS, - actionsCache.restoreCache([statusFile], cacheKey3), + actionsCache.restoreCache([statusFile], cacheKey3, [cacheKey3]), () => { logger2.warning("Timed out restoring overlay status from cache."); } @@ -174140,6 +174140,7 @@ async function downloadTrapCaches(codeql, languages, logger2) { const found = await waitForResultWithTimeLimit( MAX_CACHE_OPERATION_MS2, actionsCache2.restoreCache([cacheDir2], preferredKey, [ + preferredKey, // Fall back to any cache with the right key prefix await cachePrefix(codeql, language) ]), @@ -175395,7 +175396,7 @@ async function downloadOverlayBaseDatabaseFromCache(codeql, config, logger2) { actionsCache3.restoreCache( [dbLocation], cacheRestoreKeyPrefix, - void 0, + [cacheRestoreKeyPrefix], { // Azure SDK download (which is the default) uses 128MB segments; see // https://github.com/actions/toolkit/blob/main/packages/cache/README.md. @@ -177680,6 +177681,7 @@ async function downloadDependencyCaches(codeql, features, languages, logger2) { } const primaryKey = await cacheKey2(codeql, features, language, patterns); const restoreKeys = [ + primaryKey, await cachePrefix2(codeql, features, language) ]; logger2.info( diff --git a/src/dependency-caching.ts b/src/dependency-caching.ts index f04d38f46c..e6495f3a7b 100644 --- a/src/dependency-caching.ts +++ b/src/dependency-caching.ts @@ -313,6 +313,7 @@ export async function downloadDependencyCaches( const primaryKey = await cacheKey(codeql, features, language, patterns); const restoreKeys: string[] = [ + primaryKey, await cachePrefix(codeql, features, language), ]; diff --git a/src/overlay/caching.ts b/src/overlay/caching.ts index d246626780..5fb76625f0 100644 --- a/src/overlay/caching.ts +++ b/src/overlay/caching.ts @@ -290,7 +290,7 @@ export async function downloadOverlayBaseDatabaseFromCache( actionsCache.restoreCache( [dbLocation], cacheRestoreKeyPrefix, - undefined, + [cacheRestoreKeyPrefix], { // Azure SDK download (which is the default) uses 128MB segments; see // https://github.com/actions/toolkit/blob/main/packages/cache/README.md. diff --git a/src/overlay/status.ts b/src/overlay/status.ts index 3acf382965..1a321af420 100644 --- a/src/overlay/status.ts +++ b/src/overlay/status.ts @@ -130,7 +130,7 @@ export async function getOverlayStatus( await fs.promises.mkdir(path.dirname(statusFile), { recursive: true }); const foundKey = await waitForResultWithTimeLimit( MAX_CACHE_OPERATION_MS, - actionsCache.restoreCache([statusFile], cacheKey), + actionsCache.restoreCache([statusFile], cacheKey, [cacheKey]), () => { logger.warning("Timed out restoring overlay status from cache."); }, diff --git a/src/trap-caching.ts b/src/trap-caching.ts index a802aac892..093b5399e2 100644 --- a/src/trap-caching.ts +++ b/src/trap-caching.ts @@ -99,6 +99,7 @@ export async function downloadTrapCaches( const found = await waitForResultWithTimeLimit( MAX_CACHE_OPERATION_MS, actionsCache.restoreCache([cacheDir], preferredKey, [ + preferredKey, // Fall back to any cache with the right key prefix await cachePrefix(codeql, language), ]),