Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hacky checksum fail #562

Merged
merged 3 commits into from
Jul 8, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/rustup-dist/src/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,25 @@ fn dl_v2_manifest<'a>(download: DownloadCfg<'a>,
update_hash: Option<&Path>,
toolchain: &ToolchainDesc) -> Result<Option<(ManifestV2, String)>> {
let manifest_url = toolchain.manifest_v2_url(download.dist_root);
let manifest_dl = try!(download_and_check(&manifest_url,
update_hash, ".toml", download));
let (manifest_file, manifest_hash) = if let Some(m) = manifest_dl { m } else { return Ok(None) };
let manifest_str = try!(utils::read_file("manifest", &manifest_file));
let manifest = try!(ManifestV2::parse(&manifest_str));
let manifest_dl_res = download_and_check(&manifest_url,
update_hash, ".toml", download);

if let Ok(manifest_dl) = manifest_dl_res {
// Downloaded ok!
let (manifest_file, manifest_hash) = if let Some(m) = manifest_dl { m } else { return Ok(None) };
let manifest_str = try!(utils::read_file("manifest", &manifest_file));
let manifest = try!(ManifestV2::parse(&manifest_str));

Ok(Some((manifest, manifest_hash)))
Ok(Some((manifest, manifest_hash)))
} else {
match *manifest_dl_res.as_ref().unwrap_err().kind() {
// Checksum failed - issue warning to try again later
ErrorKind::ChecksumFailed{url: _, expected: _, calculated: _} => (download.notify_handler)(Notification::ManifestChecksumFailedHack),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace these three wildcard field patterns with { .. }.

_ => {},
}
Err(manifest_dl_res.unwrap_err())
}

}

fn dl_v1_manifest<'a>(download: DownloadCfg<'a>,
Expand Down
5 changes: 4 additions & 1 deletion src/rustup-dist/src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub enum Notification<'a> {
InstallingComponent(&'a str, &'a TargetTriple, &'a TargetTriple),
DownloadingManifest(&'a str),
DownloadingLegacyManifest,
ManifestChecksumFailedHack,
}

impl<'a> From<rustup_utils::Notification<'a>> for Notification<'a> {
Expand Down Expand Up @@ -54,7 +55,8 @@ impl<'a> Notification<'a> {
ComponentAlreadyInstalled(_) |
RollingBack | DownloadingManifest(_) => NotificationLevel::Info,
CantReadUpdateHash(_) | ExtensionNotInstalled(_) |
MissingInstalledComponent(_) => NotificationLevel::Warn,
MissingInstalledComponent(_) |
ManifestChecksumFailedHack => NotificationLevel::Warn,
NonFatalError(_) => NotificationLevel::Error,
}
}
Expand Down Expand Up @@ -101,6 +103,7 @@ impl<'a> Display for Notification<'a> {
}
DownloadingManifest(t) => write!(f, "syncing channel updates for '{}'", t),
DownloadingLegacyManifest => write!(f, "manifest not found. trying legacy manifest"),
ManifestChecksumFailedHack => write!(f, "update not yet available, sorry! try again later"),
}
}
}
Expand Down