Skip to content

Commit

Permalink
fix: use mtime instead of birthtime to determine latest cache file
Browse files Browse the repository at this point in the history
  • Loading branch information
axe312ger committed Sep 26, 2021
1 parent e72fe1a commit 46a3550
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
12 changes: 4 additions & 8 deletions dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5227,16 +5227,12 @@ function locateCacheFile(filenameMatchers, cacheFiles) {
const latestCacheFile = potentialCaches
.sort((a, b) => {
var _a, _b;
const birthtimeA = ((_a = a.stats) === null || _a === void 0 ? void 0 : _a.birthtimeMs) || 0;
const birthtimeB = ((_b = b.stats) === null || _b === void 0 ? void 0 : _b.birthtimeMs) || 0;
return birthtimeA > birthtimeB
? 1
: birthtimeB > birthtimeA
? -1
: 0;
const mtimeA = ((_a = a.stats) === null || _a === void 0 ? void 0 : _a.mtimeMs) || 0;
const mtimeB = ((_b = b.stats) === null || _b === void 0 ? void 0 : _b.mtimeMs) || 0;
return mtimeA > mtimeB ? 1 : mtimeB > mtimeA ? -1 : 0;
})
.pop();
console.log({ potentialCaches, latestCacheFile });
// console.log({ potentialCaches, latestCacheFile });
if (!latestCacheFile) {
return null;
}
Expand Down
12 changes: 4 additions & 8 deletions dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5317,16 +5317,12 @@ function locateCacheFile(filenameMatchers, cacheFiles) {
const latestCacheFile = potentialCaches
.sort((a, b) => {
var _a, _b;
const birthtimeA = ((_a = a.stats) === null || _a === void 0 ? void 0 : _a.birthtimeMs) || 0;
const birthtimeB = ((_b = b.stats) === null || _b === void 0 ? void 0 : _b.birthtimeMs) || 0;
return birthtimeA > birthtimeB
? 1
: birthtimeB > birthtimeA
? -1
: 0;
const mtimeA = ((_a = a.stats) === null || _a === void 0 ? void 0 : _a.mtimeMs) || 0;
const mtimeB = ((_b = b.stats) === null || _b === void 0 ? void 0 : _b.mtimeMs) || 0;
return mtimeA > mtimeB ? 1 : mtimeB > mtimeA ? -1 : 0;
})
.pop();
console.log({ potentialCaches, latestCacheFile });
// console.log({ potentialCaches, latestCacheFile });
if (!latestCacheFile) {
return null;
}
Expand Down
14 changes: 5 additions & 9 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,14 @@ function locateCacheFile(

const latestCacheFile = potentialCaches
.sort((a, b) => {
const birthtimeA = a.stats?.birthtimeMs || 0;
const birthtimeB = b.stats?.birthtimeMs || 0;

return birthtimeA > birthtimeB
? 1
: birthtimeB > birthtimeA
? -1
: 0;
const mtimeA = a.stats?.mtimeMs || 0;
const mtimeB = b.stats?.mtimeMs || 0;

return mtimeA > mtimeB ? 1 : mtimeB > mtimeA ? -1 : 0;
})
.pop();

console.log({ potentialCaches, latestCacheFile });
// console.log({ potentialCaches, latestCacheFile });

if (!latestCacheFile) {
return null;
Expand Down

0 comments on commit 46a3550

Please sign in to comment.