Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't preserve linked toolchains. #125

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 42 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,7 @@ fn print_results(cfg: &Config, client: &Client, bisection_result: &BisectionResu
let r = match t.install(&client, &dl_spec) {
Ok(()) => {
let outcome = t.test(&cfg);
if !cfg.args.preserve {
let _ = t.remove(&dl_spec);
}
remove_toolchain(cfg, t, &dl_spec);
// we want to fail, so a successful build doesn't satisfy us
match outcome {
TestOutcome::Baseline => Satisfies::No,
Expand Down Expand Up @@ -698,6 +696,45 @@ fn print_results(cfg: &Config, client: &Client, bisection_result: &BisectionResu
eprintln!();
}

fn remove_toolchain(cfg: &Config, toolchain: &Toolchain, dl_params: &DownloadParams) {
if cfg.args.preserve {
// If `rustup toolchain link` was used to link to nightly, then even
// with --preserve, the toolchain link should be removed, otherwise it
// will go stale after 24 hours.
let toolchain_dir = cfg.toolchains_path.join(toolchain.rustup_name());
match fs::symlink_metadata(&toolchain_dir) {
Ok(meta) => {
#[cfg(windows)]
let is_junction = {
use std::os::windows::fs::MetadataExt;
(meta.file_attributes() & 1024) != 0
};
#[cfg(not(windows))]
let is_junction = false;
if !meta.file_type().is_symlink() && !is_junction {
return;
}
debug!("removing linked toolchain {}", toolchain);
}
Err(e) => {
debug!(
"remove_toolchain: cannot stat toolchain {}: {}",
toolchain, e
);
return;
}
}
}
if let Err(e) = toolchain.remove(dl_params) {
debug!(
"failed to remove toolchain {} in {}: {}",
toolchain,
cfg.toolchains_path.display(),
e
);
}
}

fn print_final_report(
cfg: &Config,
nightly_bisection_result: &BisectionResult,
Expand Down Expand Up @@ -859,16 +896,12 @@ fn install_and_test(
TestOutcome::Regressed => Satisfies::Yes,
};
eprintln!("RESULT: {}, ===> {}", t, r);
if !cfg.args.preserve {
let _ = t.remove(&dl_spec);
}
remove_toolchain(cfg, t, &dl_spec);
eprintln!();
Ok(r)
}
Err(error) => {
if !cfg.args.preserve {
let _ = t.remove(&dl_spec);
}
remove_toolchain(cfg, t, &dl_spec);
Err(error)
}
}
Expand Down