Skip to content

Commit

Permalink
Merge pull request #428 from cramertj/master
Browse files Browse the repository at this point in the history
Added error for downloading bogus versions
  • Loading branch information
brson committed May 10, 2016
2 parents 12c67e2 + 0cba9cc commit a9fa226
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/rustup-dist/src/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl TargetTriple {
if let Some(triple) = option_env!("RUSTUP_OVERRIDE_HOST_TRIPLE") {
TargetTriple::from_str(triple)
} else {
TargetTriple::from_str(include_str!(concat!(env!("OUT_DIR"), "/target.txt")))
TargetTriple::from_str(include_str!(concat!(env!("OUT_DIR"), "/target.txt")))
}
}
}
Expand Down Expand Up @@ -432,10 +432,14 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
toolchain.manifest_name()));
}
};
match try!(manifestation.update_v1(&manifest, update_hash,
&download.temp_cfg, download.notify_handler.clone())) {
None => Ok(None),
Some(hash) => Ok(Some(hash)),
match manifestation.update_v1(&manifest, update_hash,
&download.temp_cfg, download.notify_handler.clone()) {
Ok(None) => Ok(None),
Ok(Some(hash)) => Ok(Some(hash)),
e @ Err(Error(ErrorKind::Utils(rustup_utils::ErrorKind::Download404 { .. }), _)) => {
e.chain_err(|| format!("could not download nonexistent rust version `{}`", toolchain_str))
}
Err(e) => Err(e)
}
}

Expand Down
9 changes: 9 additions & 0 deletions tests/cli-self-update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,15 @@ fn update_download_404() {
});
}

#[test]
fn update_bogus_version() {
update_setup(&|config, self_dist| {
expect_ok(config, &["rustup-init", "-y"]);
expect_err(config, &["rustup", "update", "1.0.0-alpha"],
"could not download nonexistent rust version `1.0.0-alpha`");
});
}

// Check that multirust.exe has changed after the update. This
// is hard for windows because the running process needs to exit
// before the new updater can delete it.
Expand Down

0 comments on commit a9fa226

Please sign in to comment.