Skip to content

Commit 2e606b2

Browse files
committed
Remove toolchain directory if initial toolchain install fails
If initial toolchain installation fails it leaves behind a directory, which confuses rustup into thinking it's installed.
1 parent ee7dab8 commit 2e606b2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/rustup-dist/src/dist.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,32 @@ 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+
if res.is_err() && fresh_install {
510+
// FIXME Ignoring cascading errors
511+
let _ = utils::remove_dir("toolchain", prefix.path(),
512+
&|n| (download.notify_handler)(n.into()));
513+
}
514+
515+
res
516+
}
517+
518+
pub fn update_from_dist_<'a>(download: DownloadCfg<'a>,
519+
update_hash: Option<&Path>,
520+
toolchain: &ToolchainDesc,
521+
prefix: &InstallPrefix,
522+
add: &[Component],
523+
remove: &[Component])
524+
-> Result<Option<String>> {
525+
500526
let toolchain_str = toolchain.to_string();
501527
let manifestation = try!(Manifestation::open(prefix.clone(), toolchain.target.clone()));
502528

0 commit comments

Comments
 (0)