3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-06-27 10:38:48 +00:00

Discard files older than 3 days from cache

This commit is contained in:
Alexander van Saase 2025-03-11 12:54:37 +01:00
parent 3abbfe0f3f
commit 2f124887c3
4 changed files with 8 additions and 8 deletions

View file

@ -87258,7 +87258,7 @@ async function cleanGit(packages) {
} }
catch { } catch { }
} }
const ONE_WEEK = 7 * 24 * 3600 * 1000; const THREE_DAYS = 3 * 24 * 3600 * 1000;
/** /**
* Removes all files or directories in `dirName` matching some criteria. * Removes all files or directories in `dirName` matching some criteria.
* *
@ -87275,7 +87275,7 @@ async function rmExcept(dirName, keepPrefix, checkTimestamp = false) {
if (checkTimestamp) { if (checkTimestamp) {
const fileName = external_path_default().join(dir.path, dirent.name); const fileName = external_path_default().join(dir.path, dirent.name);
const { mtime } = await external_fs_default().promises.stat(fileName); const { mtime } = await external_fs_default().promises.stat(fileName);
const isOutdated = Date.now() - mtime.getTime() > ONE_WEEK; const isOutdated = Date.now() - mtime.getTime() > THREE_DAYS;
if (isOutdated) { if (isOutdated) {
await rm(dir.path, dirent); await rm(dir.path, dirent);
} }

6
dist/save/index.js vendored
View file

@ -87258,7 +87258,7 @@ async function cleanGit(packages) {
} }
catch { } catch { }
} }
const ONE_WEEK = 7 * 24 * 3600 * 1000; const THREE_DAYS = 3 * 24 * 3600 * 1000;
/** /**
* Removes all files or directories in `dirName` matching some criteria. * Removes all files or directories in `dirName` matching some criteria.
* *
@ -87275,7 +87275,7 @@ async function rmExcept(dirName, keepPrefix, checkTimestamp = false) {
if (checkTimestamp) { if (checkTimestamp) {
const fileName = external_path_default().join(dir.path, dirent.name); const fileName = external_path_default().join(dir.path, dirent.name);
const { mtime } = await external_fs_default().promises.stat(fileName); const { mtime } = await external_fs_default().promises.stat(fileName);
const isOutdated = Date.now() - mtime.getTime() > ONE_WEEK; const isOutdated = Date.now() - mtime.getTime() > THREE_DAYS;
if (isOutdated) { if (isOutdated) {
await rm(dir.path, dirent); await rm(dir.path, dirent);
} }
@ -87351,7 +87351,7 @@ async function run() {
allPackages.push(...packages); allPackages.push(...packages);
try { try {
core.info(`... Cleaning ${workspace.target} ...`); core.info(`... Cleaning ${workspace.target} ...`);
await cleanTargetDir(workspace.target, packages); await cleanTargetDir(workspace.target, packages, true);
} }
catch (e) { catch (e) {
core.debug(`${e.stack}`); core.debug(`${e.stack}`);

View file

@ -253,7 +253,7 @@ export async function cleanGit(packages: Packages) {
} catch {} } catch {}
} }
const ONE_WEEK = 7 * 24 * 3600 * 1000; const THREE_DAYS = 3 * 24 * 3600 * 1000;
/** /**
* Removes all files or directories in `dirName` matching some criteria. * Removes all files or directories in `dirName` matching some criteria.
@ -271,7 +271,7 @@ async function rmExcept(dirName: string, keepPrefix: Set<string>, checkTimestamp
if (checkTimestamp) { if (checkTimestamp) {
const fileName = path.join(dir.path, dirent.name); const fileName = path.join(dir.path, dirent.name);
const { mtime } = await fs.promises.stat(fileName); const { mtime } = await fs.promises.stat(fileName);
const isOutdated = Date.now() - mtime.getTime() > ONE_WEEK; const isOutdated = Date.now() - mtime.getTime() > THREE_DAYS;
if (isOutdated) { if (isOutdated) {
await rm(dir.path, dirent); await rm(dir.path, dirent);

View file

@ -47,7 +47,7 @@ async function run() {
allPackages.push(...packages); allPackages.push(...packages);
try { try {
core.info(`... Cleaning ${workspace.target} ...`); core.info(`... Cleaning ${workspace.target} ...`);
await cleanTargetDir(workspace.target, packages); await cleanTargetDir(workspace.target, packages, true);
} catch (e) { } catch (e) {
core.debug(`${(e as any).stack}`); core.debug(`${(e as any).stack}`);
} }