mirror of
https://github.com/Swatinem/rust-cache
synced 2025-08-07 13:51:24 +00:00
move target clean
This commit is contained in:
parent
3231cccdde
commit
0381560ff9
4 changed files with 83 additions and 84 deletions
54
dist/restore/index.js
vendored
54
dist/restore/index.js
vendored
|
@ -87075,35 +87075,35 @@ 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);
|
||||||
// Keep the incremental folder if incremental builds are enabled
|
|
||||||
if (incremental) {
|
|
||||||
except.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
|
|
||||||
const contents = JSON.stringify({ modifiedTimes });
|
|
||||||
await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents);
|
|
||||||
}
|
|
||||||
await rmExcept(profileDir, except, checkTimestamp);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let keepProfile = new Set(["build", ".fingerprint", "deps"]);
|
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} with ${modifiedTimes} files`);
|
||||||
|
const contents = JSON.stringify({ modifiedTimes });
|
||||||
|
await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents);
|
||||||
|
}
|
||||||
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 { }
|
||||||
}
|
}
|
||||||
|
|
52
dist/save/index.js
vendored
52
dist/save/index.js
vendored
|
@ -87075,35 +87075,35 @@ 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);
|
||||||
// Keep the incremental folder if incremental builds are enabled
|
|
||||||
if (incremental) {
|
|
||||||
except.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
|
|
||||||
const contents = JSON.stringify({ modifiedTimes });
|
|
||||||
await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents);
|
|
||||||
}
|
|
||||||
await rmExcept(profileDir, except, checkTimestamp);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let keepProfile = new Set(["build", ".fingerprint", "deps"]);
|
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
|
||||||
|
core.debug(`writing incremental-restore.json for ${incrementalDir} with ${modifiedTimes} files`);
|
||||||
|
const contents = JSON.stringify({ modifiedTimes });
|
||||||
|
await external_fs_default().promises.writeFile(external_path_default().join(incrementalDir, "incremental-restore.json"), contents);
|
||||||
|
}
|
||||||
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);
|
||||||
|
|
|
@ -51,40 +51,39 @@ 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);
|
||||||
|
|
||||||
// Keep the incremental folder if incremental builds are enabled
|
|
||||||
if (incremental) {
|
|
||||||
except.add("incremental");
|
|
||||||
|
|
||||||
// Traverse the incremental folder recursively and collect the modified times in a map
|
|
||||||
const incrementalDir = path.join(profileDir, "incremental");
|
|
||||||
const modifiedTimes = new Map<string, number>();
|
|
||||||
const fillModifiedTimes = async (dir: string) => {
|
|
||||||
const dirEntries = await fs.promises.opendir(dir);
|
|
||||||
for await (const dirent of dirEntries) {
|
|
||||||
if (dirent.isDirectory()) {
|
|
||||||
await fillModifiedTimes(path.join(dir, dirent.name));
|
|
||||||
} else {
|
|
||||||
const fileName = path.join(dir, dirent.name);
|
|
||||||
const { mtime } = await fs.promises.stat(fileName);
|
|
||||||
modifiedTimes.set(fileName, mtime.getTime());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
await fillModifiedTimes(incrementalDir);
|
|
||||||
|
|
||||||
// Write the modified times to the incremental folder
|
|
||||||
const contents = JSON.stringify({ modifiedTimes });
|
|
||||||
await fs.promises.writeFile(path.join(incrementalDir, "incremental-restore.json"), contents);
|
|
||||||
}
|
|
||||||
|
|
||||||
await rmExcept(profileDir, except, checkTimestamp);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let keepProfile = new Set(["build", ".fingerprint", "deps"]);
|
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 = path.join(profileDir, "incremental");
|
||||||
|
const modifiedTimes = new Map<string, number>();
|
||||||
|
const fillModifiedTimes = async (dir: string) => {
|
||||||
|
const dirEntries = await fs.promises.opendir(dir);
|
||||||
|
for await (const dirent of dirEntries) {
|
||||||
|
if (dirent.isDirectory()) {
|
||||||
|
await fillModifiedTimes(path.join(dir, dirent.name));
|
||||||
|
} else {
|
||||||
|
const fileName = path.join(dir, dirent.name);
|
||||||
|
const { mtime } = await fs.promises.stat(fileName);
|
||||||
|
modifiedTimes.set(fileName, mtime.getTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await fillModifiedTimes(incrementalDir);
|
||||||
|
|
||||||
|
// Write the modified times to the incremental folder
|
||||||
|
core.debug(`writing incremental-restore.json for ${incrementalDir} with ${modifiedTimes} files`);
|
||||||
|
const contents = JSON.stringify({ modifiedTimes });
|
||||||
|
await fs.promises.writeFile(path.join(incrementalDir, "incremental-restore.json"), contents);
|
||||||
|
}
|
||||||
|
|
||||||
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));
|
||||||
|
|
|
@ -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 { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue