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

Don't make it an error for the self-update hash to be wrong #372

Merged
merged 1 commit into from
May 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 2 additions & 6 deletions src/rustup-cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use itertools::Itertools;
use rustup::{NotifyHandler};
use errors::*;
use rustup_dist::dist;
use rustup_dist;
use rustup_utils::utils;
use openssl::crypto::hash::{Type, Hasher};
use std::env;
Expand Down Expand Up @@ -1077,11 +1076,8 @@ pub fn prepare_update() -> Result<Option<PathBuf>> {

// Check that hash is correct
if latest_hash != download_hash {
return Err(ErrorKind::Dist(rustup_dist::ErrorKind::ChecksumFailed {
url: url,
expected: latest_hash,
calculated: download_hash,
}).into());
info!("update not yet available. bug #364");
return Ok(None);
}

// Mark as executable
Expand Down
23 changes: 21 additions & 2 deletions tests/cli-self-update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ use std::process::Command;
use rustup_mock::clitools::{self, Config, Scenario,
expect_ok, expect_ok_ex,
expect_stdout_ok,
expect_stderr_ok,
expect_err, expect_err_ex,
this_host_triple};
#[cfg(windows)]
use rustup_mock::clitools::expect_stderr_ok;
use rustup_mock::dist::{create_hash, calc_hash};
use rustup_mock::{get_path, restore_path};
use rustup_utils::raw;
Expand Down Expand Up @@ -520,6 +519,7 @@ info: rustup is up to date
}

#[test]
#[ignore] // Workaround for #346
fn update_bad_hash() {
update_setup(&|config, self_dist| {
expect_ok(config, &["rustup-init", "-y"]);
Expand All @@ -537,6 +537,25 @@ fn update_bad_hash() {
});
}

// Workaround for #346
#[test]
fn update_hash_drift() {
update_setup(&|config, self_dist| {
expect_ok(config, &["rustup-init", "-y"]);

let ref trip = this_host_triple();
let ref dist_dir = self_dist.join(&format!("{}", trip));
let ref dist_hash = dist_dir.join(&format!("rustup-init{}.sha256", EXE_SUFFIX));

let ref some_other_file = config.distdir.join("dist/channel-rust-nightly.toml");

create_hash(some_other_file, dist_hash);

expect_stderr_ok(config, &["rustup", "self", "update"],
"update not yet available");
});
}

#[test]
fn update_hash_file_404() {
update_setup(&|config, self_dist| {
Expand Down