Skip to content

Commit e819b3a

Browse files
committed
This updates the remove function to remove the installed directory
unconditionally. This is a sort of scary thing to do, so I added a safe-guard to double-check that whatever directory we are removing, it is one of the ones starts with "bisector" and thus is something cargo-bisect-rustc is implicitly in charge of.
1 parent 661b76d commit e819b3a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/main.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl Toolchain {
269269
match self.spec {
270270
ToolchainSpec::Ci { ref commit, alt } => {
271271
let alt_s = if alt { format!("-alt") } else { String::new() };
272-
format!("ci-{}{}-{}", commit, alt_s, self.host)
272+
format!("bisector-ci-{}{}-{}", commit, alt_s, self.host)
273273
}
274274
// N.B. We need to call this with a nonstandard name so that rustup utilizes the
275275
// fallback cargo logic.
@@ -494,11 +494,15 @@ impl Toolchain {
494494
}
495495

496496
fn remove(&self, dl_params: &DownloadParams) -> Result<(), Error> {
497-
if !self.is_current_nightly() {
498-
eprintln!("uninstalling {}", self);
499-
let dir = dl_params.install_dir.join(self.rustup_name());
500-
fs::remove_dir_all(&dir)?;
501-
}
497+
eprintln!("uninstalling {}", self);
498+
let rustup_name = self.rustup_name();
499+
500+
// Guard aginst destroying directories that this tool didn't create.
501+
assert!(rustup_name.starts_with("bisector-nightly") ||
502+
rustup_name.starts_with("bisector-ci"));
503+
504+
let dir = dl_params.install_dir.join(rustup_name);
505+
fs::remove_dir_all(&dir)?;
502506

503507
Ok(())
504508
}

0 commit comments

Comments
 (0)