Skip to content

Commit f8f6b6e

Browse files
committed
Realized there was another case where we delete directories "blindly": forced installs.
Extended safeguard from previous commit to cover that case too.
1 parent e819b3a commit f8f6b6e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,14 @@ impl Toolchain {
495495

496496
fn remove(&self, dl_params: &DownloadParams) -> Result<(), Error> {
497497
eprintln!("uninstalling {}", self);
498+
self.do_remove(dl_params)
499+
}
500+
501+
/// Removes the (previously installed) bisector rustc described by `dl_params`.
502+
///
503+
/// The main reason to call this (instead of `fs::remove_dir_all` directly)
504+
/// is to guard against deleting state not managed by `cargo-bisect-rustc`.
505+
fn do_remove(&self, dl_params: &DownloadParams) -> Result<(), Error> {
498506
let rustup_name = self.rustup_name();
499507

500508
// Guard aginst destroying directories that this tool didn't create.
@@ -711,7 +719,7 @@ impl Toolchain {
711719
.map_err(InstallError::TempDir)?;
712720
let dest = dl_params.install_dir.join(self.rustup_name());
713721
if dl_params.force_install {
714-
let _ = fs::remove_dir_all(&dest);
722+
let _ = self.do_remove(dl_params);
715723
}
716724

717725
if dest.is_dir() {

0 commit comments

Comments
 (0)