- // #102002, cleanup stage1 and stage0-sysroot folders when using download-rustc so people don't use old versions of the toolchain by accident.
- let _ = fs::remove_dir_all(host_dir.join("stage1"));
- let _ = fs::remove_dir_all(host_dir.join("stage0-sysroot"));
+ // #102002, cleanup old toolchain folders when using download-rustc so people don't use them by accident.
+ for stage in 0..=2 {
+ if stage != compiler.stage {
+ let dir = sysroot_dir(stage);
+ if !dir.ends_with("ci-rustc-sysroot") {
+ let _ = fs::remove_dir_all(dir);
+ }
+ }
+ }