@@ -6,16 +6,17 @@ use std::str::FromStr;
66use anyhow:: { Context , Result , anyhow, bail} ;
77use serde:: Deserialize ;
88use thiserror:: Error as ThisError ;
9- use tokio_stream:: StreamExt ;
109use tracing:: { debug, error, info, trace, warn} ;
1110
12- use crate :: dist:: AutoInstallMode ;
1311use crate :: {
1412 cli:: { common, self_update:: SelfUpdateMode } ,
15- dist:: { self , PartialToolchainDesc , Profile , TargetTriple , ToolchainDesc , temp} ,
13+ dist:: {
14+ self , AutoInstallMode , DistOptions , PartialToolchainDesc , Profile , TargetTriple ,
15+ ToolchainDesc , temp,
16+ } ,
1617 errors:: RustupError ,
1718 fallback_settings:: FallbackSettings ,
18- install:: UpdateStatus ,
19+ install:: { InstallMethod , UpdateStatus } ,
1920 process:: Process ,
2021 settings:: { MetadataVersion , Settings , SettingsFile } ,
2122 toolchain:: {
@@ -797,29 +798,31 @@ impl<'a> Cfg<'a> {
797798 }
798799 let components: Vec < _ > = components. iter ( ) . map ( AsRef :: as_ref) . collect ( ) ;
799800 let targets: Vec < _ > = targets. iter ( ) . map ( AsRef :: as_ref) . collect ( ) ;
800- let profile = match profile {
801- Some ( profile) => profile,
802- None => self . get_profile ( ) ?,
803- } ;
801+ let mut options = DistOptions :: new (
802+ & components,
803+ & targets,
804+ toolchain,
805+ match profile {
806+ Some ( p) => p,
807+ None => self . get_profile ( ) ?,
808+ } ,
809+ false ,
810+ self ,
811+ ) ?;
812+
804813 let ( status, toolchain) = match DistributableToolchain :: new ( self , toolchain. clone ( ) ) {
805814 Err ( RustupError :: ToolchainNotInstalled { .. } ) => {
806- DistributableToolchain :: install (
807- self ,
808- toolchain,
809- & components,
810- & targets,
811- profile,
812- false ,
813- skip_std,
814- )
815- . await ?
815+ DistributableToolchain :: install ( options) . await ?
816816 }
817- Ok ( mut distributable) => {
817+ Ok ( distributable) => {
818818 if verbose {
819819 info ! ( "using existing install for {toolchain}" ) ;
820820 }
821821 let status = if !distributable. components_exist ( & components, & targets) ? {
822- distributable. update ( & components, & targets, profile) . await ?
822+ options. force = true ;
823+ InstallMethod :: Dist ( options. for_update ( & distributable, false ) )
824+ . install ( )
825+ . await ?
823826 } else {
824827 UpdateStatus :: Unchanged
825828 } ;
@@ -903,28 +906,6 @@ impl<'a> Cfg<'a> {
903906 } )
904907 }
905908
906- pub ( crate ) async fn update_all_channels (
907- & self ,
908- force_update : bool ,
909- ) -> Result < Vec < ( ToolchainDesc , Result < UpdateStatus > ) > > {
910- let channels = self . list_channels ( ) ?;
911- let channels = channels. into_iter ( ) ;
912- let profile = self . get_profile ( ) ?;
913-
914- // Update toolchains and collect the results
915- let channels = tokio_stream:: iter ( channels) . then ( |( desc, mut distributable) | async move {
916- let st = distributable
917- . update_extra ( & [ ] , & [ ] , profile, force_update, false )
918- . await ;
919- if let Err ( e) = & st {
920- error ! ( "{e}" ) ;
921- }
922- ( desc, st)
923- } ) ;
924-
925- Ok ( channels. collect ( ) . await )
926- }
927-
928909 pub ( crate ) fn set_default_host_triple ( & self , host_triple : String ) -> Result < ( ) > {
929910 // Ensure that the provided host_triple is capable of resolving
930911 // against the 'stable' toolchain. This provides early errors
@@ -954,7 +935,7 @@ impl<'a> Cfg<'a> {
954935
955936/// The root path of the release server, without the `/dist` suffix.
956937/// By default, it points to [`dist::DEFAULT_DIST_SERVER`].
957- pub ( crate ) fn dist_root_server ( process : & Process ) -> Result < String > {
938+ fn dist_root_server ( process : & Process ) -> Result < String > {
958939 if let Some ( s) = process. var_opt ( "RUSTUP_DIST_SERVER" ) ? {
959940 trace ! ( "`RUSTUP_DIST_SERVER` has been set to `{s}`" ) ;
960941 return Ok ( s) ;
0 commit comments