3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-08-07 22:01:24 +00:00

move target clean

This commit is contained in:
Jonathan Kelley 2025-01-28 19:03:35 -08:00
parent 3231cccdde
commit 0381560ff9
No known key found for this signature in database
GPG key ID: 1FBB50F7EB0A08BE
4 changed files with 83 additions and 84 deletions

14
dist/restore/index.js vendored
View file

@ -87075,10 +87075,13 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp, incremen
} }
catch { } catch { }
// Delete everything else. // Delete everything else.
let except = new Set(["target", "trybuild"]); await rmExcept(profileDir, new Set(["target", "trybuild"]), checkTimestamp);
return;
}
let keepProfile = new Set(["build", ".fingerprint", "deps"]);
// Keep the incremental folder if incremental builds are enabled // Keep the incremental folder if incremental builds are enabled
if (incremental) { if (incremental) {
except.add("incremental"); keepProfile.add("incremental");
// Traverse the incremental folder recursively and collect the modified times in a map // Traverse the incremental folder recursively and collect the modified times in a map
const incrementalDir = external_path_default().join(profileDir, "incremental"); const incrementalDir = external_path_default().join(profileDir, "incremental");
const modifiedTimes = new Map(); const modifiedTimes = new Map();
@ -87097,13 +87100,10 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp, incremen
}; };
await fillModifiedTimes(incrementalDir); await fillModifiedTimes(incrementalDir);
// Write the modified times to the incremental folder // Write the modified times to the incremental folder
lib_core.debug(`writing incremental-restore.json for ${incrementalDir} with ${modifiedTimes} files`);
const contents = JSON.stringify({ modifiedTimes }); const contents = JSON.stringify({ modifiedTimes });
await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents); await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents);
} }
await rmExcept(profileDir, except, checkTimestamp);
return;
}
let keepProfile = new Set(["build", ".fingerprint", "deps"]);
await rmExcept(profileDir, keepProfile); await rmExcept(profileDir, keepProfile);
const keepPkg = new Set(packages.map((p) => p.name)); const keepPkg = new Set(packages.map((p) => p.name));
await rmExcept(external_path_default().join(profileDir, "build"), keepPkg, checkTimestamp); await rmExcept(external_path_default().join(profileDir, "build"), keepPkg, checkTimestamp);
@ -87437,7 +87437,7 @@ async function run() {
// pre-clean the target directory on cache mismatch // pre-clean the target directory on cache mismatch
for (const workspace of config.workspaces) { for (const workspace of config.workspaces) {
try { try {
await cleanTargetDir(workspace.target, [], true, false); await cleanTargetDir(workspace.target, [], true, config.incremental);
} }
catch { } catch { }
} }

12
dist/save/index.js vendored
View file

@ -87075,10 +87075,13 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp, incremen
} }
catch { } catch { }
// Delete everything else. // Delete everything else.
let except = new Set(["target", "trybuild"]); await rmExcept(profileDir, new Set(["target", "trybuild"]), checkTimestamp);
return;
}
let keepProfile = new Set(["build", ".fingerprint", "deps"]);
// Keep the incremental folder if incremental builds are enabled // Keep the incremental folder if incremental builds are enabled
if (incremental) { if (incremental) {
except.add("incremental"); keepProfile.add("incremental");
// Traverse the incremental folder recursively and collect the modified times in a map // Traverse the incremental folder recursively and collect the modified times in a map
const incrementalDir = external_path_default().join(profileDir, "incremental"); const incrementalDir = external_path_default().join(profileDir, "incremental");
const modifiedTimes = new Map(); const modifiedTimes = new Map();
@ -87097,13 +87100,10 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp, incremen
}; };
await fillModifiedTimes(incrementalDir); await fillModifiedTimes(incrementalDir);
// Write the modified times to the incremental folder // Write the modified times to the incremental folder
core.debug(`writing incremental-restore.json for ${incrementalDir} with ${modifiedTimes} files`);
const contents = JSON.stringify({ modifiedTimes }); const contents = JSON.stringify({ modifiedTimes });
await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents); await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents);
} }
await rmExcept(profileDir, except, checkTimestamp);
return;
}
let keepProfile = new Set(["build", ".fingerprint", "deps"]);
await rmExcept(profileDir, keepProfile); await rmExcept(profileDir, keepProfile);
const keepPkg = new Set(packages.map((p) => p.name)); const keepPkg = new Set(packages.map((p) => p.name));
await rmExcept(external_path_default().join(profileDir, "build"), keepPkg, checkTimestamp); await rmExcept(external_path_default().join(profileDir, "build"), keepPkg, checkTimestamp);

View file

@ -51,11 +51,15 @@ async function cleanProfileTarget(profileDir: string, packages: Packages, checkT
} catch { } } catch { }
// Delete everything else. // Delete everything else.
let except = new Set(["target", "trybuild"]); await rmExcept(profileDir, new Set(["target", "trybuild"]), checkTimestamp);
return;
}
let keepProfile = new Set(["build", ".fingerprint", "deps"]);
// Keep the incremental folder if incremental builds are enabled // Keep the incremental folder if incremental builds are enabled
if (incremental) { if (incremental) {
except.add("incremental"); keepProfile.add("incremental");
// Traverse the incremental folder recursively and collect the modified times in a map // Traverse the incremental folder recursively and collect the modified times in a map
const incrementalDir = path.join(profileDir, "incremental"); const incrementalDir = path.join(profileDir, "incremental");
@ -75,16 +79,11 @@ async function cleanProfileTarget(profileDir: string, packages: Packages, checkT
await fillModifiedTimes(incrementalDir); await fillModifiedTimes(incrementalDir);
// Write the modified times to the incremental folder // Write the modified times to the incremental folder
core.debug(`writing incremental-restore.json for ${incrementalDir} with ${modifiedTimes} files`);
const contents = JSON.stringify({ modifiedTimes }); const contents = JSON.stringify({ modifiedTimes });
await fs.promises.writeFile(path.join(incrementalDir, "incremental-restore.json"), contents); await fs.promises.writeFile(path.join(incrementalDir, "incremental-restore.json"), contents);
} }
await rmExcept(profileDir, except, checkTimestamp);
return;
}
let keepProfile = new Set(["build", ".fingerprint", "deps"]);
await rmExcept(profileDir, keepProfile); await rmExcept(profileDir, keepProfile);
const keepPkg = new Set(packages.map((p) => p.name)); const keepPkg = new Set(packages.map((p) => p.name));

View file

@ -60,7 +60,7 @@ async function run() {
// pre-clean the target directory on cache mismatch // pre-clean the target directory on cache mismatch
for (const workspace of config.workspaces) { for (const workspace of config.workspaces) {
try { try {
await cleanTargetDir(workspace.target, [], true, false); await cleanTargetDir(workspace.target, [], true, config.incremental);
} catch { } } catch { }
} }