Skip to content

Commit e6b867b

Browse files
authored
Merge pull request #573 from brson/fallback
Fallback to old download methods if server returns 403
2 parents ee7dab8 + a0a9e59 commit e6b867b

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/rustup-dist/src/dist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
518518
}
519519
}
520520
Ok(None) => return Ok(None),
521-
Err(Error(ErrorKind::Utils(::rustup_utils::ErrorKind::Download404 { .. }), _)) => {
521+
Err(Error(ErrorKind::Utils(::rustup_utils::ErrorKind::DownloadNotExists { .. }), _)) => {
522522
// Proceed to try v1 as a fallback
523523
(download.notify_handler)(Notification::DownloadingLegacyManifest);
524524
}
@@ -528,7 +528,7 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
528528
// If the v2 manifest is not found then try v1
529529
let manifest = match dl_v1_manifest(download, toolchain) {
530530
Ok(m) => m,
531-
Err(Error(ErrorKind::Utils(rustup_utils::ErrorKind::Download404 { .. }), _)) => {
531+
Err(Error(ErrorKind::Utils(rustup_utils::ErrorKind::DownloadNotExists { .. }), _)) => {
532532
return Err(format!("no release found for '{}'", toolchain.manifest_name()).into());
533533
}
534534
Err(e @ Error(ErrorKind::ChecksumFailed { .. }, _)) => {
@@ -547,7 +547,7 @@ pub fn update_from_dist<'a>(download: DownloadCfg<'a>,
547547
download.notify_handler.clone()) {
548548
Ok(None) => Ok(None),
549549
Ok(Some(hash)) => Ok(Some(hash)),
550-
e @ Err(Error(ErrorKind::Utils(rustup_utils::ErrorKind::Download404 { .. }), _)) => {
550+
e @ Err(Error(ErrorKind::Utils(rustup_utils::ErrorKind::DownloadNotExists { .. }), _)) => {
551551
e.chain_err(|| {
552552
format!("could not download nonexistent rust version `{}`",
553553
toolchain_str)

src/rustup-utils/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ error_chain! {
8181
description("could not download file")
8282
display("could not download file from '{}' to '{}", url, path.display())
8383
}
84-
Download404 {
84+
DownloadNotExists {
8585
url: Url,
8686
path: PathBuf,
8787
} {

src/rustup-utils/src/utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,13 @@ pub fn download_file(url: &Url,
150150
Err(e) => {
151151
let is404 = match e.kind() {
152152
&ErrorKind::Download(DEK::HttpStatus(404)) => true,
153+
// 403 is what static.rlo returns for bogus URLs as of 2016/07/11
154+
&ErrorKind::Download(DEK::HttpStatus(403)) => true,
153155
&ErrorKind::Download(DEK::FileNotFound) => true,
154156
_ => false
155157
};
156158
Err(e).chain_err(|| if is404 {
157-
ErrorKind::Download404 {
159+
ErrorKind::DownloadNotExists {
158160
url: url.clone(),
159161
path: path.to_path_buf(),
160162
}

0 commit comments

Comments
 (0)