Skip to content

Commit

Permalink
feat(dist): refine suggestions regarding manifest checksum mismatches
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Jul 8, 2024
1 parent e16e606 commit c0fefc3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ impl<'a> Cfg<'a> {
}
}

fn dist_root_server(process: &Process) -> Cow<'static, str> {
pub(crate) fn dist_root_server(process: &Process) -> Cow<'static, str> {
process
.var("RUSTUP_DIST_SERVER")
.ok()
Expand Down
27 changes: 22 additions & 5 deletions src/dist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ use once_cell::sync::Lazy;
use regex::Regex;
use serde::{Deserialize, Serialize};
use thiserror::Error as ThisError;
use tracing::info;
use tracing::{info, warn};

use crate::{
config::Cfg, currentprocess::Process, errors::RustupError, toolchain::ToolchainName,
config::{dist_root_server, Cfg},
currentprocess::Process,
errors::RustupError,
toolchain::ToolchainName,
utils::utils,
};

Expand Down Expand Up @@ -1166,9 +1169,23 @@ pub(crate) async fn dl_v2_manifest(
Ok(Some((manifest, manifest_hash)))
}
Err(any) => {
if let Some(RustupError::ChecksumFailed { .. }) = any.downcast_ref::<RustupError>() {
// Checksum failed - issue warning to try again later
info!("update not yet available, sorry! try again later")
if let Some(err @ RustupError::ChecksumFailed { .. }) =
any.downcast_ref::<RustupError>()
{
// Manifest checksum mismatched.
warn!("{err}");

let server = dist_root_server(download.process);
if server == DEFAULT_DIST_SERVER {
// This might indicate a transient state during an update
// on the official release server
// (see <https://github.com/rust-lang/rustup/issues/3390>)
info!("this is likely due to an ongoing update of the official release server, please try again later");
} else {
// This could also indicate a misconfiguration of a third-party release server
// (see <https://github.com/rust-lang/rustup/issues/3885>).
info!("this might indicate an issue with the third-party release server `{server}`");
}
}
Err(any)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/suite/cli_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ async fn bad_sha_on_manifest() {
cx.config
.expect_err(
&["rustup", "default", "nightly"],
"update not yet available",
"info: this might indicate an issue with the third-party release server",
)
.await;
}
Expand Down

0 comments on commit c0fefc3

Please sign in to comment.