Skip to content

Commit 7c9e51a

Browse files
authored
Merge pull request #2781 from kinnison/pre-1.8-refetch
Prevent need to refetch for v1 manifests
2 parents 6b094f7 + 992ab57 commit 7c9e51a

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

src/bin/rustup-init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn run_rustup_inner() -> Result<utils::ExitCode> {
9595
}
9696
Some(n) => {
9797
if TOOLS.iter().chain(DUP_TOOLS.iter()).any(|&name| name == n) {
98-
proxy_mode::main()
98+
proxy_mode::main(n)
9999
} else {
100100
Err(anyhow!(format!(
101101
"unknown proxy name: '{}'; valid proxy names are {}",

src/cli/proxy_mode.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
use std::ffi::OsString;
2-
use std::path::PathBuf;
32
use std::process;
43

54
use anyhow::Result;
65

76
use super::common::set_globals;
8-
use super::errors::*;
97
use super::job;
108
use super::self_update;
119
use crate::command::run_command_for_dir;
1210
use crate::utils::utils::{self, ExitCode};
1311
use crate::Cfg;
1412

15-
pub fn main() -> Result<ExitCode> {
13+
pub fn main(arg0: &str) -> Result<ExitCode> {
1614
self_update::cleanup_self_updater()?;
1715

1816
let ExitCode(c) = {
1917
let _setup = job::setup();
2018

21-
let mut args = crate::process().args_os();
22-
23-
let arg0 = args.next().map(PathBuf::from);
24-
let arg0 = arg0
25-
.as_ref()
26-
.and_then(|a| a.file_name())
27-
.and_then(std::ffi::OsStr::to_str);
28-
let arg0 = arg0.ok_or(CLIError::NoExeName)?;
19+
let mut args = crate::process().args_os().skip(1);
2920

3021
// Check for a toolchain specifier.
3122
let arg1 = args.next();

src/config.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,10 @@ impl Cfg {
740740
let manifest = if let Some(manifest) = distributable.get_manifest()? {
741741
manifest
742742
} else {
743-
// If we can't read the manifest we'd best try and install
744-
return Ok(false);
743+
// We can't read the manifest. If this is a v1 install that's understandable
744+
// and we assume the components are all good, otherwise we need to have a go
745+
// at re-fetching the manifest to try again.
746+
return Ok(distributable.guess_v1_manifest());
745747
};
746748
match (distributable.list_components(), components_requested) {
747749
// If the toolchain does not support components but there were components requested, bubble up the error

src/toolchain.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ pub enum UpdateStatus {
6464
Unchanged,
6565
}
6666

67+
static V1_COMMON_COMPONENT_LIST: &[&str] = &["cargo", "rustc", "rust-docs"];
68+
6769
impl<'a> Toolchain<'a> {
6870
pub fn from(cfg: &'a Cfg, name: &str) -> Result<Self> {
6971
let resolved_name = cfg.resolve_toolchain(name)?;
@@ -953,6 +955,23 @@ impl<'a> DistributableToolchain<'a> {
953955
fn update_hash(&self) -> Result<PathBuf> {
954956
self.0.cfg.get_hash_file(&self.0.name, true)
955957
}
958+
959+
// Installed only.
960+
pub fn guess_v1_manifest(&self) -> bool {
961+
let prefix = InstallPrefix::from(self.0.path().to_owned());
962+
// If all the v1 common components are present this is likely to be
963+
// a v1 manifest install. The v1 components are not called the same
964+
// in a v2 install.
965+
for component in V1_COMMON_COMPONENT_LIST {
966+
let manifest = format!("manifest-{}", component);
967+
let manifest_path = prefix.manifest_file(&manifest);
968+
if !utils::path_exists(manifest_path) {
969+
return false;
970+
}
971+
}
972+
// It's reasonable to assume this is a v1 manifest installation
973+
true
974+
}
956975
}
957976

958977
impl<'a> InstalledToolchain<'a> for DistributableToolchain<'a> {

0 commit comments

Comments
 (0)