@@ -34434,10 +34434,10 @@ async function getCacheProvider() {
3443434434 let cache;
3443534435 switch (cacheProvider) {
3443634436 case "github":
34437- cache = await import('./cache-CxTjXol0 .js');
34437+ cache = await import('./cache-CTfQoCTL .js');
3443834438 break;
3443934439 case "warpbuild":
34440- cache = await import('./cache-DhiwylR9 .js').then(function (n) { return n.c; });
34440+ cache = await import('./cache-DC26rUaF .js').then(function (n) { return n.c; });
3444134441 break;
3444234442 default:
3444334443 throw new Error(`The \`cache-provider\` \`${cacheProvider}\` is not valid.`);
@@ -34569,14 +34569,9 @@ class CacheConfig {
3456934569 // The env vars are sorted, matched by prefix and hashed into the
3457034570 // resulting environment hash.
3457134571 let hasher = crypto__default.createHash("sha1");
34572- const rustVersions = Array.from(await getRustVersions(cmdFormat));
34573- // Doesn't matter how they're sorted, just as long as it's deterministic.
34574- rustVersions.sort();
34572+ const rustVersions = (self.keyRust = await getRustVersions(cmdFormat));
3457534573 for (const rustVersion of rustVersions) {
34576- const { release, host, "commit-hash": commitHash } = rustVersion;
34577- const keyRust = `${release} ${host} ${commitHash}`;
34578- hasher.update(keyRust);
34579- self.keyRust.push(keyRust);
34574+ hasher.update(rustVersion);
3458034575 }
3458134576 // these prefixes should cover most of the compiler / rust / cargo keys
3458234577 const envPrefixes = ["CARGO", "CC", "CFLAGS", "CXX", "CMAKE", "RUST"];
@@ -34835,15 +34830,19 @@ async function getRustVersions(cmdFormat) {
3483534830 versions.add(parseRustVersion(await getCmdOutput(cmdFormat, `rustup run ${toolchain} rustc -vV`)));
3483634831 }
3483734832 }
34838- return versions;
34833+ const rustVersions = Array.from(versions);
34834+ // Doesn't matter how they're sorted, just as long as it's deterministic.
34835+ rustVersions.sort();
34836+ return rustVersions;
3483934837}
3484034838function parseRustVersion(stdout) {
3484134839 const splits = stdout
3484234840 .split(/[\n\r]+/)
3484334841 .filter(Boolean)
3484434842 .map((s) => s.split(":").map((s) => s.trim()))
3484534843 .filter((s) => s.length === 2);
34846- return Object.fromEntries(splits);
34844+ const { release, host, "commit-hash": commitHash } = Object.fromEntries(splits);
34845+ return `${release} ${host} ${commitHash}`;
3484734846}
3484834847async function globFiles(pattern) {
3484934848 const globber = await create(pattern, {
@@ -34885,14 +34884,18 @@ async function cleanTargetDir(targetDir, packages, checkTimestamp = false) {
3488534884 for await (const dirent of dir) {
3488634885 if (dirent.isDirectory()) {
3488734886 let dirName = path__default.join(dir.path, dirent.name);
34888- // is it a profile dir, or a nested target dir?
34889- let isNestedTarget = (await exists(path__default.join(dirName, "CACHEDIR.TAG"))) || (await exists(path__default.join(dirName, ".rustc_info.json")));
34887+ // Target-triple directories do not contain Cargo's target directory
34888+ // markers, so identify profiles by their artifact directories as well.
34889+ const isProfile = dirent.name === "tests" ||
34890+ (await exists(path__default.join(dirName, "build"))) ||
34891+ (await exists(path__default.join(dirName, ".fingerprint"))) ||
34892+ (await exists(path__default.join(dirName, "deps")));
3489034893 try {
34891- if (isNestedTarget ) {
34892- await cleanTargetDir (dirName, packages, checkTimestamp);
34894+ if (isProfile ) {
34895+ await cleanProfileTarget (dirName, packages, checkTimestamp);
3489334896 }
3489434897 else {
34895- await cleanProfileTarget (dirName, packages, checkTimestamp);
34898+ await cleanTargetDir (dirName, packages, checkTimestamp);
3489634899 }
3489734900 }
3489834901 catch { }
@@ -35102,6 +35105,12 @@ const ONE_WEEK = 7 * 24 * 3600 * 1000;
3510235105 * Otherwise, it will remove everything that does not match any string in the
3510335106 * `keepPrefix` set.
3510435107 * The matching strips and trailing `-$hash` suffix.
35108+ *
35109+ * Cargo's newer `build-dir` layout (rust-lang/cargo#17258) nests the hash as
35110+ * a subdirectory instead of appending it, so entries there are bare package
35111+ * names with no suffix to strip. Check for an exact match first so those
35112+ * names (which may themselves contain hyphens) aren't mistaken for a
35113+ * `<name>-<hash>` entry from the old layout and truncated incorrectly.
3510535114 */
3510635115async function rmExcept(dirName, keepPrefix, checkTimestamp = false) {
3510735116 const dir = await fs__default.promises.opendir(dirName);
@@ -35116,13 +35125,20 @@ async function rmExcept(dirName, keepPrefix, checkTimestamp = false) {
3511635125 return;
3511735126 }
3511835127 let name = dirent.name;
35119- // strip the trailing hash
35120- const idx = name.lastIndexOf("-");
35121- if (idx !== -1) {
35122- name = name.slice(0, idx);
35123- }
35128+ // in Cargo's V1 layout, all packages are suffixed by their hash.
35129+ // in V2, all package hashes are subdirectories instead.
35130+ // Check both possible naming standards for packages and accept either.
35131+ // v2 package format
3512435132 if (!keepPrefix.has(name)) {
35125- await rm(dir.path, dirent);
35133+ // now check for v1 package format
35134+ // strip the trailing hash
35135+ const idx = name.lastIndexOf("-");
35136+ if (idx !== -1) {
35137+ name = name.slice(0, idx);
35138+ }
35139+ if (!keepPrefix.has(name)) {
35140+ await rm(dir.path, dirent);
35141+ }
3512635142 }
3512735143 }
3512835144}
0 commit comments