Skip to content

Commit

Permalink
Added error for downloading bogus versions
Browse files Browse the repository at this point in the history
  • Loading branch information
cramertj committed May 10, 2016
1 parent ea58711 commit 36a3420
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/rustup-dist/src/dist.rs
Original file line number Diff line number Diff line change
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)),
Err(Error(ErrorKind::Utils(rustup_utils::ErrorKind::Download404 { .. }), e)) => {
Err(Error(ErrorKind::Utils(rustup_utils::ErrorKind::Download404BadVers { vers: toolchain_str }), e))
},
Err(e) => Err(e)
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/rustup-utils/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ error_chain! {
description("could not download file")
display("could not download file from '{}' to '{}", url, path.display())
}
Download404BadVers {
vers: String
} {
description("could not download nonexistent rust version")
display("could not download nonexistent rust version `{}`", vers)
}
Download404 {
url: hyper::Url,
path: PathBuf,
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 36a3420

Please sign in to comment.