Skip to content

Commit

Permalink
restore exact match when no restoreKeys are given
Browse files Browse the repository at this point in the history
  • Loading branch information
axe312ger committed May 28, 2021
1 parent 21e6ee4 commit ce408ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,9 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
// @todo order files by name/date
yield streamOutputUntilResolved(mkdirPromise);
const cacheFiles = yield readDirAsync(cacheDir);
const potentialCaches = (restoreKeys || [primaryKey]).map(key => filenamify_1.default(key));
const potentialCaches = (Array.isArray(restoreKeys) && restoreKeys.length
? restoreKeys
: [primaryKey]).map(key => filenamify_1.default(key));
console.log({ cacheFiles, potentialCaches });
const result = locateCache(potentialCaches, cacheFiles);
if (typeof result !== "object") {
Expand Down
4 changes: 3 additions & 1 deletion dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,9 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
// @todo order files by name/date
yield streamOutputUntilResolved(mkdirPromise);
const cacheFiles = yield readDirAsync(cacheDir);
const potentialCaches = (restoreKeys || [primaryKey]).map(key => filenamify_1.default(key));
const potentialCaches = (Array.isArray(restoreKeys) && restoreKeys.length
? restoreKeys
: [primaryKey]).map(key => filenamify_1.default(key));
console.log({ cacheFiles, potentialCaches });
const result = locateCache(potentialCaches, cacheFiles);
if (typeof result !== "object") {
Expand Down
7 changes: 4 additions & 3 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ export async function restoreCache(

const cacheFiles = await readDirAsync(cacheDir);

const potentialCaches = (restoreKeys || [primaryKey]).map(key =>
filenamify(key)
);
const potentialCaches = (Array.isArray(restoreKeys) && restoreKeys.length
? restoreKeys
: [primaryKey]
).map(key => filenamify(key));

console.log({ cacheFiles, potentialCaches });

Expand Down

0 comments on commit ce408ed

Please sign in to comment.