Skip to content

Commit 2c6837e

Browse files
rami3lMark-Simulacrum
authored andcommitted
fix(main)!: change dist path for rustc-docs
1 parent 44a5f66 commit 2c6837e

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

src/main.rs

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -507,36 +507,39 @@ impl Context {
507507
fs::create_dir_all(&rustc_docs)?;
508508

509509
// Construct the path that contains the documentation inside the tarball.
510-
let tarball_dir = format!("{tarball_prefix}/rustc-docs/share/doc/rust/html");
511-
let tarball_dir_new = format!("{tarball_dir}/rustc");
512-
513-
if Command::new("tar")
514-
.arg("tf")
515-
.arg(&tarball)
516-
.arg(&tarball_dir_new)
517-
.current_dir(&rustc_docs)
518-
.output()?
519-
.status
520-
.success()
521-
{
522-
// Unpack the rustc documentation into the new directory.
523-
// // Touch all files as well (see above for why).
524-
run(Command::new("tar")
525-
.arg("xfm")
526-
.arg(&tarball)
527-
.arg("--strip-components=7")
528-
.arg(&tarball_dir_new)
529-
.current_dir(&rustc_docs))?;
530-
} else {
531-
// Unpack the rustc documentation into the new directory.
532-
// Touch all files as well (see above for why).
533-
run(Command::new("tar")
534-
.arg("xfm")
510+
let tarball_dir_base = format!("{tarball_prefix}/rustc-docs/share/doc/rust/html");
511+
512+
// NOTE: The following logic is to accommodate the 2 latest `rustc-docs` structures:
513+
// - New path: `share/doc/rust/html/rustc-docs/...`
514+
// - Old path (fallback): `share/doc/rust/html/rustc/...`
515+
let mut tarball_dir = None;
516+
for subdir in ["rustc-docs", "rustc"] {
517+
let candidate = format!("{tarball_dir_base}/{subdir}");
518+
if Command::new("tar")
519+
.arg("tf")
535520
.arg(&tarball)
536-
.arg("--strip-components=6")
537-
.arg(&tarball_dir)
538-
.current_dir(&rustc_docs))?;
521+
.arg(&candidate)
522+
.current_dir(&rustc_docs)
523+
.output()?
524+
.status
525+
.success()
526+
{
527+
// The candidate directory exists in the tarball.
528+
tarball_dir = Some(candidate);
529+
break;
530+
}
539531
}
532+
let Some(tarball_dir) = tarball_dir else {
533+
anyhow::bail!("could not find the rustc documentation in the tarball");
534+
};
535+
// Unpack the rustc documentation into the new directory.
536+
// Touch all files as well (see above for why).
537+
run(Command::new("tar")
538+
.arg("xfm")
539+
.arg(&tarball)
540+
.arg("--strip-components=7")
541+
.arg(&tarball_dir)
542+
.current_dir(&rustc_docs))?;
540543
}
541544

542545
// Upload this to `/doc/$channel`

0 commit comments

Comments
 (0)