Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cache): Trigger cacache to remove expired contents #28275

Merged
merged 8 commits into from
Apr 9, 2024
6 changes: 6 additions & 0 deletions lib/util/cache/package/file.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ describe('util/cache/package/file', () => {
await set('_test-namespace', 'valid', 1234);
await set('_test-namespace', 'expired', 1234, -5);
await cacache.put(cacheFileName, 'invalid', 'not json');
const expiredDigest = (
await cacache.get(cacheFileName, '_test-namespace-expired')
).integrity;
await cleanup();
const entries = await cacache.ls(cacheFileName);
expect(Object.keys(entries)).toEqual(['_test-namespace-valid']);
await expect(
cacache.get.byDigest(cacheFileName, expiredDigest),
).rejects.toThrow('ENOENT');
});
});
1 change: 1 addition & 0 deletions lib/util/cache/package/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export async function cleanup(): Promise<void> {
deletedCount += 1;
}
}
await cacache.verify(cacheFileName);
gg-kialo marked this conversation as resolved.
Show resolved Hide resolved
const durationMs = Math.round(Date.now() - startTime);
logger.debug(
`Deleted ${deletedCount} of ${totalCount} file cached entries in ${durationMs}ms`,
Expand Down
Loading