From 90585346ca4ef9aa70dbe7ae071c84b863c7b6f8 Mon Sep 17 00:00:00 2001 From: rami3l Date: Mon, 22 Dec 2025 21:42:52 +0100 Subject: [PATCH] fix(main)!: change dist path for `rustc-docs` --- src/main.rs | 59 ++++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/src/main.rs b/src/main.rs index 305b8a1..01eef78 100644 --- a/src/main.rs +++ b/src/main.rs @@ -507,36 +507,39 @@ impl Context { fs::create_dir_all(&rustc_docs)?; // Construct the path that contains the documentation inside the tarball. - let tarball_dir = format!("{tarball_prefix}/rustc-docs/share/doc/rust/html"); - let tarball_dir_new = format!("{tarball_dir}/rustc"); - - if Command::new("tar") - .arg("tf") - .arg(&tarball) - .arg(&tarball_dir_new) - .current_dir(&rustc_docs) - .output()? - .status - .success() - { - // Unpack the rustc documentation into the new directory. - // // Touch all files as well (see above for why). - run(Command::new("tar") - .arg("xfm") - .arg(&tarball) - .arg("--strip-components=7") - .arg(&tarball_dir_new) - .current_dir(&rustc_docs))?; - } else { - // Unpack the rustc documentation into the new directory. - // Touch all files as well (see above for why). - run(Command::new("tar") - .arg("xfm") + let tarball_dir_base = format!("{tarball_prefix}/rustc-docs/share/doc/rust/html"); + + // NOTE: The following logic is to accommodate the 2 latest `rustc-docs` structures: + // - New path: `share/doc/rust/html/rustc-docs/...` + // - Old path (fallback): `share/doc/rust/html/rustc/...` + let mut tarball_dir = None; + for subdir in ["rustc-docs", "rustc"] { + let candidate = format!("{tarball_dir_base}/{subdir}"); + if Command::new("tar") + .arg("tf") .arg(&tarball) - .arg("--strip-components=6") - .arg(&tarball_dir) - .current_dir(&rustc_docs))?; + .arg(&candidate) + .current_dir(&rustc_docs) + .output()? + .status + .success() + { + // The candidate directory exists in the tarball. + tarball_dir = Some(candidate); + break; + } } + let Some(tarball_dir) = tarball_dir else { + anyhow::bail!("could not find the rustc documentation in the tarball"); + }; + // Unpack the rustc documentation into the new directory. + // Touch all files as well (see above for why). + run(Command::new("tar") + .arg("xfm") + .arg(&tarball) + .arg("--strip-components=7") + .arg(&tarball_dir) + .current_dir(&rustc_docs))?; } // Upload this to `/doc/$channel`