Skip to content

Commit

Permalink
fix: cache restore failures (#136)
Browse files Browse the repository at this point in the history
Fix cache restore failures to to upstream bug.

Fixes #119
  • Loading branch information
stevenh committed May 11, 2023
1 parent 127a0e9 commit 5e9fae9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion dist/restore/index.js
Expand Up @@ -60403,7 +60403,10 @@ async function run() {
lib_core.saveState(config_STATE_BINS, JSON.stringify([...bins]));
lib_core.info(`... Restoring cache ...`);
const key = config.cacheKey;
const restoreKey = await cache.restoreCache(config.cachePaths, key, [config.restoreKey]);
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
// https://github.com/actions/toolkit/pull/1378
// TODO: remove this once the underlying bug is fixed.
const restoreKey = await cache.restoreCache(config.cachePaths.slice(), key, [config.restoreKey]);
if (restoreKey) {
lib_core.info(`Restored from cache key "${restoreKey}".`);
lib_core.saveState(STATE_KEY, restoreKey);
Expand Down
5 changes: 4 additions & 1 deletion dist/save/index.js
Expand Up @@ -60434,7 +60434,10 @@ async function run() {
core.info(`[warning] ${e.stack}`);
}
core.info(`... Saving cache ...`);
await cache.saveCache(config.cachePaths, config.cacheKey);
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
// https://github.com/actions/toolkit/pull/1378
// TODO: remove this once the underlying bug is fixed.
await cache.saveCache(config.cachePaths.slice(), config.cacheKey);
}
catch (e) {
core.info(`[warning] ${e.stack}`);
Expand Down
5 changes: 4 additions & 1 deletion src/restore.ts
Expand Up @@ -34,7 +34,10 @@ async function run() {

core.info(`... Restoring cache ...`);
const key = config.cacheKey;
const restoreKey = await cache.restoreCache(config.cachePaths, key, [config.restoreKey]);
// Pass a copy of cachePaths to avoid mutating the original array as reported by:
// https://github.com/actions/toolkit/pull/1378
// TODO: remove this once the underlying bug is fixed.
const restoreKey = await cache.restoreCache(config.cachePaths.slice(), key, [config.restoreKey]);
if (restoreKey) {
core.info(`Restored from cache key "${restoreKey}".`);
core.saveState(STATE_KEY, restoreKey);
Expand Down
5 changes: 4 additions & 1 deletion src/save.ts
Expand Up @@ -66,7 +66,10 @@ async function run() {
}

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

0 comments on commit 5e9fae9

Please sign in to comment.