Skip to content

Commit

Permalink
Merge pull request #574 from brson/delete
Browse files Browse the repository at this point in the history
Remove toolchain directory if initial toolchain install fails
  • Loading branch information
alexcrichton authored Jul 12, 2016
2 parents e6b867b + 9cc6517 commit 011f79a
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 011f79a

Please sign in to comment.