Skip to content

Commit

Permalink
Don't make it an error for the self-update hash to be wrong
Browse files Browse the repository at this point in the history
We've got problems with the updater and its hash being out
of sync. Thes patch considers a hash failure here a temporary
problem, prints a status message and exits with success.

cc rust-lang#346
  • Loading branch information
brson committed Apr 29, 2016
1 parent 4a40aa8 commit f110a8e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
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

0 comments on commit f110a8e

Please sign in to comment.