Skip to content

Commit 5e9fae9

Browse files
authored
fix: cache restore failures (#136)
Fix cache restore failures to to upstream bug. Fixes #119
1 parent 127a0e9 commit 5e9fae9

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

dist/restore/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60403,7 +60403,10 @@ async function run() {
6040360403
lib_core.saveState(config_STATE_BINS, JSON.stringify([...bins]));
6040460404
lib_core.info(`... Restoring cache ...`);
6040560405
const key = config.cacheKey;
60406-
const restoreKey = await cache.restoreCache(config.cachePaths, key, [config.restoreKey]);
60406+
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
60407+
// https://github.com/actions/toolkit/pull/1378
60408+
// TODO: remove this once the underlying bug is fixed.
60409+
const restoreKey = await cache.restoreCache(config.cachePaths.slice(), key, [config.restoreKey]);
6040760410
if (restoreKey) {
6040860411
lib_core.info(`Restored from cache key "${restoreKey}".`);
6040960412
lib_core.saveState(STATE_KEY, restoreKey);

dist/save/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60434,7 +60434,10 @@ async function run() {
6043460434
core.info(`[warning] ${e.stack}`);
6043560435
}
6043660436
core.info(`... Saving cache ...`);
60437-
await cache.saveCache(config.cachePaths, config.cacheKey);
60437+
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
60438+
// https://github.com/actions/toolkit/pull/1378
60439+
// TODO: remove this once the underlying bug is fixed.
60440+
await cache.saveCache(config.cachePaths.slice(), config.cacheKey);
6043860441
}
6043960442
catch (e) {
6044060443
core.info(`[warning] ${e.stack}`);

src/restore.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ async function run() {
3434

3535
core.info(`... Restoring cache ...`);
3636
const key = config.cacheKey;
37-
const restoreKey = await cache.restoreCache(config.cachePaths, key, [config.restoreKey]);
37+
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
38+
// https://github.com/actions/toolkit/pull/1378
39+
// TODO: remove this once the underlying bug is fixed.
40+
const restoreKey = await cache.restoreCache(config.cachePaths.slice(), key, [config.restoreKey]);
3841
if (restoreKey) {
3942
core.info(`Restored from cache key "${restoreKey}".`);
4043
core.saveState(STATE_KEY, restoreKey);

src/save.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ async function run() {
6666
}
6767

6868
core.info(`... Saving cache ...`);
69-
await cache.saveCache(config.cachePaths, config.cacheKey);
69+
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
70+
// https://github.com/actions/toolkit/pull/1378
71+
// TODO: remove this once the underlying bug is fixed.
72+
await cache.saveCache(config.cachePaths.slice(), config.cacheKey);
7073
} catch (e) {
7174
core.info(`[warning] ${(e as any).stack}`);
7275
}

0 commit comments

Comments
 (0)