3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2026-08-09 23:11:04 +00:00

invert target/profile check in cleanup

closes #356
This commit is contained in:
Arpad Borsos 2026-08-06 08:17:41 +02:00
parent 6e5b278ead
commit 3bf42ac996
No known key found for this signature in database
GPG key ID: FC7BCA77824B3298

View file

@ -15,15 +15,19 @@ export async function cleanTargetDir(targetDir: string, packages: Packages, chec
for await (const dirent of dir) {
if (dirent.isDirectory()) {
let dirName = path.join(dir.path, dirent.name);
// is it a profile dir, or a nested target dir?
let isNestedTarget =
(await exists(path.join(dirName, "CACHEDIR.TAG"))) || (await exists(path.join(dirName, ".rustc_info.json")));
// Target-triple directories do not contain Cargo's target directory
// markers, so identify profiles by their artifact directories as well.
const isProfile =
dirent.name === "tests" ||
(await exists(path.join(dirName, "build"))) ||
(await exists(path.join(dirName, ".fingerprint"))) ||
(await exists(path.join(dirName, "deps")));
try {
if (isNestedTarget) {
await cleanTargetDir(dirName, packages, checkTimestamp);
} else {
if (isProfile) {
await cleanProfileTarget(dirName, packages, checkTimestamp);
} else {
await cleanTargetDir(dirName, packages, checkTimestamp);
}
} catch {}
} else if (dirent.name !== "CACHEDIR.TAG") {