Skip to content

Commit 1b64788

Browse files
committed
Correctly handle update across missing nightlies
Fixes #2001.
1 parent 279e802 commit 1b64788

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

src/dist/dist.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ fn update_from_dist_<'a>(
629629
if first_err.is_none() {
630630
first_err = Some(e);
631631
}
632+
} else if let ErrorKind::MissingReleaseForToolchain(..) = e.kind() {
633+
// no need to even print anything for missing nightlies,
634+
// since we don't really "skip" them
632635
} else if let Some(e) = first_err {
633636
// if we fail to find a suitable nightly, we abort the search and give the
634637
// original "components unavailable for download" error.
@@ -721,7 +724,9 @@ fn try_update_from_dist_<'a>(
721724
let manifest = match dl_v1_manifest(download, toolchain) {
722725
Ok(m) => m,
723726
Err(Error(crate::ErrorKind::DownloadNotExists { .. }, _)) => {
724-
return Err(format!("no release found for '{}'", toolchain.manifest_name()).into());
727+
return Err(Error::from(ErrorKind::MissingReleaseForToolchain(
728+
toolchain.manifest_name(),
729+
)));
725730
}
726731
Err(e @ Error(ErrorKind::ChecksumFailed { .. }, _)) => {
727732
return Err(e);

src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ error_chain! {
275275
description("missing package for the target of a rename")
276276
display("server sent a broken manifest: missing package for the target of a rename {}", name)
277277
}
278+
MissingReleaseForToolchain(name: String) {
279+
description("missing release for a toolchain")
280+
display("no release found for '{}'", name)
281+
}
278282
RequestedComponentsUnavailable(c: Vec<Component>, manifest: Manifest, toolchain: String) {
279283
description("some requested components are unavailable to download")
280284
display("{}", component_unavailable_msg(&c, &manifest, &toolchain))

tests/cli-misc.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,14 +771,16 @@ fn update_nightly_even_with_incompat() {
771771

772772
#[test]
773773
fn nightly_backtrack_skips_missing() {
774-
clitools::setup(Scenario::Unavailable, &|config| {
775-
set_current_dist_date(config, "2015-01-01");
774+
clitools::setup(Scenario::MissingNightly, &|config| {
775+
set_current_dist_date(config, "2019-09-16");
776776
expect_ok(config, &["rustup", "default", "nightly"]);
777777

778778
expect_stdout_ok(config, &["rustc", "--version"], "hash-nightly-1");
779+
expect_ok(config, &["rustup", "component", "add", "rls"]);
780+
expect_component_executable(config, "rls");
779781

780-
// nightly is missing on latest
781-
set_current_dist_date(config, "2015-01-02");
782+
// rls is missing on latest, nightly is missing on second-to-latest
783+
set_current_dist_date(config, "2019-09-18");
782784

783785
// update should not change nightly, and should not error
784786
expect_ok(config, &["rustup", "update", "nightly", "--no-self-update"]);

tests/mock/clitools.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub enum Scenario {
5252
Unavailable, // Two dates, v2 manifests, everything unavailable in second date.
5353
UnavailableRls, // Two dates, v2 manifests, RLS unavailable in first date, restored on second.
5454
MissingComponent, // Three dates, v2 manifests, RLS available in first and last, not middle
55+
MissingNightly, // Three dates, v2 manifests, RLS available in first, middle missing nightly
5556
}
5657

5758
pub static CROSS_ARCH1: &str = "x86_64-unknown-linux-musl";
@@ -564,6 +565,11 @@ fn create_mock_dist_server(path: &Path, s: Scenario) {
564565
Release::new("nightly", "1.37.0", "2019-09-13", "2"),
565566
Release::new("nightly", "1.37.0", "2019-09-14", "3").with_rls(RlsStatus::Unavailable),
566567
],
568+
Scenario::MissingNightly => vec![
569+
Release::new("nightly", "1.37.0", "2019-09-16", "1"),
570+
Release::stable("1.37.0", "2019-09-17"),
571+
Release::new("nightly", "1.37.0", "2019-09-18", "2").with_rls(RlsStatus::Unavailable),
572+
],
567573
Scenario::Unavailable => vec![
568574
Release::new("nightly", "1.2.0", "2015-01-01", "1"),
569575
Release::beta("1.1.0", "2015-01-01"),
@@ -606,6 +612,7 @@ fn create_mock_dist_server(path: &Path, s: Scenario) {
606612
| Scenario::MultiHost
607613
| Scenario::Unavailable
608614
| Scenario::UnavailableRls
615+
| Scenario::MissingNightly
609616
| Scenario::MissingComponent => vec![ManifestVersion::V2],
610617
};
611618

0 commit comments

Comments
 (0)