@@ -6,7 +6,7 @@ use anyhow::Result;
66
77use crate :: {
88 config:: Cfg ,
9- dist:: { self , download :: DownloadCfg , prefix:: InstallPrefix , Notification } ,
9+ dist:: { self , prefix:: InstallPrefix , DistOptions , Notification } ,
1010 errors:: RustupError ,
1111 notifications:: Notification as RootNotification ,
1212 toolchain:: { CustomToolchainName , LocalToolchainName , Toolchain } ,
@@ -32,25 +32,7 @@ pub(crate) enum InstallMethod<'a> {
3232 dest : & ' a CustomToolchainName ,
3333 cfg : & ' a Cfg < ' a > ,
3434 } ,
35- Dist {
36- cfg : & ' a Cfg < ' a > ,
37- desc : & ' a dist:: ToolchainDesc ,
38- profile : dist:: Profile ,
39- update_hash : Option < & ' a Path > ,
40- dl_cfg : DownloadCfg < ' a > ,
41- /// --force bool is whether to force an update/install
42- force : bool ,
43- /// --allow-downgrade
44- allow_downgrade : bool ,
45- /// toolchain already exists
46- exists : bool ,
47- /// currently installed date and version
48- old_date_version : Option < ( String , String ) > ,
49- /// Extra components to install from dist
50- components : & ' a [ & ' a str ] ,
51- /// Extra targets to install from dist
52- targets : & ' a [ & ' a str ] ,
53- } ,
35+ Dist ( DistOptions < ' a > ) ,
5436}
5537
5638impl < ' a > InstallMethod < ' a > {
@@ -61,10 +43,10 @@ impl<'a> InstallMethod<'a> {
6143 match self {
6244 InstallMethod :: Copy { .. }
6345 | InstallMethod :: Link { .. }
64- | InstallMethod :: Dist {
46+ | InstallMethod :: Dist ( DistOptions {
6547 old_date_version : None ,
6648 ..
67- } => ( nh) ( RootNotification :: InstallingToolchain ( & self . dest_basename ( ) ) ) ,
49+ } ) => ( nh) ( RootNotification :: InstallingToolchain ( & self . dest_basename ( ) ) ) ,
6850 _ => ( nh) ( RootNotification :: UpdatingToolchain ( & self . dest_basename ( ) ) ) ,
6951 }
7052
@@ -83,10 +65,10 @@ impl<'a> InstallMethod<'a> {
8365 true => {
8466 ( nh) ( RootNotification :: InstalledToolchain ( & self . dest_basename ( ) ) ) ;
8567 match self {
86- InstallMethod :: Dist {
68+ InstallMethod :: Dist ( DistOptions {
8769 old_date_version : Some ( ( _, v) ) ,
8870 ..
89- } => UpdateStatus :: Updated ( v. clone ( ) ) ,
71+ } ) => UpdateStatus :: Updated ( v. clone ( ) ) ,
9072 InstallMethod :: Copy { .. }
9173 | InstallMethod :: Link { .. }
9274 | InstallMethod :: Dist { .. } => UpdateStatus :: Installed ,
@@ -121,36 +103,12 @@ impl<'a> InstallMethod<'a> {
121103 utils:: symlink_dir ( src, path, notify_handler) ?;
122104 Ok ( true )
123105 }
124- InstallMethod :: Dist {
125- desc,
126- profile,
127- update_hash,
128- dl_cfg,
129- force : force_update,
130- allow_downgrade,
131- exists,
132- old_date_version,
133- components,
134- targets,
135- ..
136- } => {
106+ InstallMethod :: Dist ( opts) => {
137107 let prefix = & InstallPrefix :: from ( path. to_owned ( ) ) ;
138- let maybe_new_hash = dist:: update_from_dist (
139- * dl_cfg,
140- update_hash. as_deref ( ) ,
141- desc,
142- if * exists { None } else { Some ( * profile) } ,
143- prefix,
144- * force_update,
145- * allow_downgrade,
146- old_date_version. as_ref ( ) . map ( |dv| dv. 0 . as_str ( ) ) ,
147- components,
148- targets,
149- )
150- . await ?;
108+ let maybe_new_hash = dist:: update_from_dist ( prefix, opts) . await ?;
151109
152110 if let Some ( hash) = maybe_new_hash {
153- if let Some ( hash_file) = update_hash {
111+ if let Some ( hash_file) = opts . update_hash {
154112 utils:: write_file ( "update hash" , hash_file, & hash) ?;
155113 }
156114
@@ -166,15 +124,15 @@ impl<'a> InstallMethod<'a> {
166124 match self {
167125 InstallMethod :: Copy { cfg, .. } => cfg,
168126 InstallMethod :: Link { cfg, .. } => cfg,
169- InstallMethod :: Dist { cfg, .. } => cfg,
127+ InstallMethod :: Dist ( DistOptions { cfg, .. } ) => cfg,
170128 }
171129 }
172130
173131 fn local_name ( & self ) -> LocalToolchainName {
174132 match self {
175133 InstallMethod :: Copy { dest, .. } => ( * dest) . into ( ) ,
176134 InstallMethod :: Link { dest, .. } => ( * dest) . into ( ) ,
177- InstallMethod :: Dist { desc, .. } => ( * desc) . into ( ) ,
135+ InstallMethod :: Dist ( DistOptions { desc, .. } ) => ( * desc) . into ( ) ,
178136 }
179137 }
180138
@@ -186,7 +144,9 @@ impl<'a> InstallMethod<'a> {
186144 match self {
187145 InstallMethod :: Copy { cfg, dest, .. } => cfg. toolchain_path ( & ( * dest) . into ( ) ) ,
188146 InstallMethod :: Link { cfg, dest, .. } => cfg. toolchain_path ( & ( * dest) . into ( ) ) ,
189- InstallMethod :: Dist { cfg, desc, .. } => cfg. toolchain_path ( & ( * desc) . into ( ) ) ,
147+ InstallMethod :: Dist ( DistOptions { cfg, desc, .. } ) => {
148+ cfg. toolchain_path ( & ( * desc) . into ( ) )
149+ }
190150 }
191151 }
192152}
0 commit comments