File tree Expand file tree Collapse file tree 4 files changed +26
-14
lines changed Expand file tree Collapse file tree 4 files changed +26
-14
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ fn run_rustup_inner() -> Result<utils::ExitCode> {
95
95
}
96
96
Some ( n) => {
97
97
if TOOLS . iter ( ) . chain ( DUP_TOOLS . iter ( ) ) . any ( |& name| name == n) {
98
- proxy_mode:: main ( )
98
+ proxy_mode:: main ( n )
99
99
} else {
100
100
Err ( anyhow ! ( format!(
101
101
"unknown proxy name: '{}'; valid proxy names are {}" ,
Original file line number Diff line number Diff line change 1
1
use std:: ffi:: OsString ;
2
- use std:: path:: PathBuf ;
3
2
use std:: process;
4
3
5
4
use anyhow:: Result ;
6
5
7
6
use super :: common:: set_globals;
8
- use super :: errors:: * ;
9
7
use super :: job;
10
8
use super :: self_update;
11
9
use crate :: command:: run_command_for_dir;
12
10
use crate :: utils:: utils:: { self , ExitCode } ;
13
11
use crate :: Cfg ;
14
12
15
- pub fn main ( ) -> Result < ExitCode > {
13
+ pub fn main ( arg0 : & str ) -> Result < ExitCode > {
16
14
self_update:: cleanup_self_updater ( ) ?;
17
15
18
16
let ExitCode ( c) = {
19
17
let _setup = job:: setup ( ) ;
20
18
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 ) ;
29
20
30
21
// Check for a toolchain specifier.
31
22
let arg1 = args. next ( ) ;
Original file line number Diff line number Diff line change @@ -740,8 +740,10 @@ impl Cfg {
740
740
let manifest = if let Some ( manifest) = distributable. get_manifest ( ) ? {
741
741
manifest
742
742
} 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 ( ) ) ;
745
747
} ;
746
748
match ( distributable. list_components ( ) , components_requested) {
747
749
// If the toolchain does not support components but there were components requested, bubble up the error
Original file line number Diff line number Diff line change @@ -64,6 +64,8 @@ pub enum UpdateStatus {
64
64
Unchanged ,
65
65
}
66
66
67
+ static V1_COMMON_COMPONENT_LIST : & [ & str ] = & [ "cargo" , "rustc" , "rust-docs" ] ;
68
+
67
69
impl < ' a > Toolchain < ' a > {
68
70
pub fn from ( cfg : & ' a Cfg , name : & str ) -> Result < Self > {
69
71
let resolved_name = cfg. resolve_toolchain ( name) ?;
@@ -953,6 +955,23 @@ impl<'a> DistributableToolchain<'a> {
953
955
fn update_hash ( & self ) -> Result < PathBuf > {
954
956
self . 0 . cfg . get_hash_file ( & self . 0 . name , true )
955
957
}
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
+ }
956
975
}
957
976
958
977
impl < ' a > InstalledToolchain < ' a > for DistributableToolchain < ' a > {
You can’t perform that action at this time.
0 commit comments