mirror of
https://github.com/Swatinem/rust-cache
synced 2025-04-27 21:55:52 +00:00
save before clearing
This commit is contained in:
parent
8c8c35255e
commit
6f58383b83
4 changed files with 86 additions and 105 deletions
28
dist/restore/index.js
vendored
28
dist/restore/index.js
vendored
|
@ -87160,34 +87160,6 @@ async function cleanProfileTarget(profileDir, packages, checkTimestamp, incremen
|
|||
return;
|
||||
}
|
||||
let keepProfile = new Set(["build", ".fingerprint", "deps"]);
|
||||
// Keep the incremental folder if incremental builds are enabled
|
||||
if (incremental) {
|
||||
keepProfile.add("incremental");
|
||||
// Traverse the incremental folder recursively and collect the modified times in a map
|
||||
const incrementalDir = external_path_default().join(profileDir, "incremental");
|
||||
const modifiedTimes = new Map();
|
||||
const fillModifiedTimes = async (dir) => {
|
||||
const dirEntries = await external_fs_default().promises.opendir(dir);
|
||||
for await (const dirent of dirEntries) {
|
||||
if (dirent.isDirectory()) {
|
||||
await fillModifiedTimes(external_path_default().join(dir, dirent.name));
|
||||
}
|
||||
else {
|
||||
const fileName = external_path_default().join(dir, dirent.name);
|
||||
const { mtime } = await external_fs_default().promises.stat(fileName);
|
||||
modifiedTimes.set(fileName, mtime.getTime());
|
||||
}
|
||||
}
|
||||
};
|
||||
await fillModifiedTimes(incrementalDir);
|
||||
// Write the modified times to the incremental folder
|
||||
lib_core.debug(`writing incremental-restore.json for ${incrementalDir} files`);
|
||||
for (const file of modifiedTimes.keys()) {
|
||||
lib_core.debug(` ${file} -> ${modifiedTimes.get(file)}`);
|
||||
}
|
||||
const contents = JSON.stringify({ modifiedTimes });
|
||||
await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents);
|
||||
}
|
||||
await rmExcept(profileDir, keepProfile);
|
||||
const keepPkg = new Set(packages.map((p) => p.name));
|
||||
await rmExcept(external_path_default().join(profileDir, "build"), keepPkg, checkTimestamp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue