Skip to content

Commit

Permalink
add further logging
Browse files Browse the repository at this point in the history
  • Loading branch information
axe312ger committed May 28, 2021
1 parent 9c0d267 commit 77cb9d2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
10 changes: 9 additions & 1 deletion dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,17 +692,25 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
const cacheDir = path_1.join(`/media/cache/`, process.env.GITHUB_REPOSITORY || "");
// 1. check if we find any dir that matches our keys from restoreKeys
const mkdirPromise = execAsync(`mkdir -p ${cacheDir}`);
// @todo order files by name/date
yield streamOutputUntilResolved(mkdirPromise);
const cacheFiles = yield readDirAsync(cacheDir);
console.log({ caches: cacheFiles });
const potentialCaches = (restoreKeys || [primaryKey]).map(generateCacheName);
console.log({ cacheFiles, potentialCaches });
const result = locateCache(potentialCaches, cacheFiles);
if (typeof result !== "object") {
console.log("Unable to locate fitting cache file", {
cacheFiles,
potentialCaches,
restoreKeys,
primaryKey
});
return undefined;
}
const { key, cache } = result;
const cachePath = path_1.join(cacheDir, cache);
const cmd = `lz4 -d -v -c ${cachePath} | tar xf - -C ${path_1.dirname(paths[0])}`;
// --skip-old-files
console.log({ cacheDir, cache, cachePath, key, cmd });
// 2. if we found one, rsync it back to the HD
const createCacheDirPromise = execAsync(cmd);
Expand Down
8 changes: 7 additions & 1 deletion dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,16 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
// @todo order files by name/date
yield streamOutputUntilResolved(mkdirPromise);
const cacheFiles = yield readDirAsync(cacheDir);
console.log({ caches: cacheFiles });
const potentialCaches = (restoreKeys || [primaryKey]).map(generateCacheName);
console.log({ cacheFiles, potentialCaches });
const result = locateCache(potentialCaches, cacheFiles);
if (typeof result !== "object") {
console.log("Unable to locate fitting cache file", {
cacheFiles,
potentialCaches,
restoreKeys,
primaryKey
});
return undefined;
}
const { key, cache } = result;
Expand Down
10 changes: 8 additions & 2 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,21 @@ export async function restoreCache(

const cacheFiles = await readDirAsync(cacheDir);

console.log({ caches: cacheFiles });

const potentialCaches = (restoreKeys || [primaryKey]).map(
generateCacheName
);

console.log({ cacheFiles, potentialCaches });

const result = locateCache(potentialCaches, cacheFiles);

if (typeof result !== "object") {
console.log("Unable to locate fitting cache file", {
cacheFiles,
potentialCaches,
restoreKeys,
primaryKey
});
return undefined;
}

Expand Down

0 comments on commit 77cb9d2

Please sign in to comment.