Skip to content

Commit 011f79a

Browse files
authored
Merge pull request #574 from brson/delete
Remove toolchain directory if initial toolchain install fails
2 parents e6b867b + 9cc6517 commit 011f79a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/rustup-dist/src/dist.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,33 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
497497
remove: &[Component])
498498
-> Result<Option<String>> {
499499

500+
let fresh_install = !prefix.path().exists();
501+
502+
let res = update_from_dist_(download,
503+
update_hash,
504+
toolchain,
505+
prefix,
506+
add,
507+
remove);
508+
509+
// Don't leave behind an empty / broken installation directory
510+
if res.is_err() && fresh_install {
511+
// FIXME Ignoring cascading errors
512+
let _ = utils::remove_dir("toolchain", prefix.path(),
513+
&|n| (download.notify_handler)(n.into()));
514+
}
515+
516+
res
517+
}
518+
519+
pub fn update_from_dist_<'a>(download: DownloadCfg<'a>,
520+
update_hash: Option<&Path>,
521+
toolchain: &ToolchainDesc,
522+
prefix: &InstallPrefix,
523+
add: &[Component],
524+
remove: &[Component])
525+
-> Result<Option<String>> {
526+
500527
let toolchain_str = toolchain.to_string();
501528
let manifestation = try!(Manifestation::open(prefix.clone(), toolchain.target.clone()));
502529

0 commit comments

Comments
 (0)