Skip to content

Commit

Permalink
Remove toolchain directory if initial toolchain install fails
Browse files Browse the repository at this point in the history
If initial toolchain installation fails it leaves behind a directory,
which confuses rustup into thinking it's installed.
  • Loading branch information
brson committed Jul 12, 2016
1 parent ee7dab8 commit 9cc6517
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/rustup-dist/src/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,33 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
remove: &[Component])
-> Result<Option<String>> {

let fresh_install = !prefix.path().exists();

let res = update_from_dist_(download,
update_hash,
toolchain,
prefix,
add,
remove);

// Don't leave behind an empty / broken installation directory
if res.is_err() && fresh_install {
// FIXME Ignoring cascading errors
let _ = utils::remove_dir("toolchain", prefix.path(),
&|n| (download.notify_handler)(n.into()));
}

res
}

pub fn update_from_dist_<'a>(download: DownloadCfg<'a>,
update_hash: Option<&Path>,
toolchain: &ToolchainDesc,
prefix: &InstallPrefix,
add: &[Component],
remove: &[Component])
-> Result<Option<String>> {

let toolchain_str = toolchain.to_string();
let manifestation = try!(Manifestation::open(prefix.clone(), toolchain.target.clone()));

Expand Down

0 comments on commit 9cc6517

Please sign in to comment.