@@ -50,6 +50,7 @@ use serde::{Deserialize, Serialize};
5050use termcolor:: Color ;
5151use tracing:: { error, info, trace, warn} ;
5252
53+ use crate :: dist:: download:: DownloadCfg ;
5354use crate :: {
5455 DUP_TOOLS , TOOLS ,
5556 cli:: {
@@ -541,7 +542,7 @@ pub(crate) async fn install(
541542 let mut term = cfg. process . stdout ( ) ;
542543
543544 #[ cfg( windows) ]
544- windows:: maybe_install_msvc ( & mut term, no_prompt, quiet , & opts, process ) . await ?;
545+ windows:: maybe_install_msvc ( & mut term, no_prompt, & opts, & * cfg ) . await ?;
545546
546547 if !no_prompt {
547548 let msg = pre_install_msg ( opts. no_modify_path , cfg. process ) ?;
@@ -576,7 +577,7 @@ pub(crate) async fn install(
576577 // window closes.
577578 #[ cfg( windows) ]
578579 if !no_prompt {
579- windows:: ensure_prompt ( process) ?;
580+ windows:: ensure_prompt ( cfg . process ) ?;
580581 }
581582
582583 return Ok ( utils:: ExitCode ( 1 ) ) ;
@@ -620,7 +621,7 @@ pub(crate) async fn install(
620621 // On windows, where installation happens in a console
621622 // that may have opened just for this purpose, require
622623 // the user to press a key to continue.
623- windows:: ensure_prompt ( process) ?;
624+ windows:: ensure_prompt ( cfg . process ) ?;
624625 }
625626
626627 Ok ( exit_code)
@@ -1105,7 +1106,7 @@ pub(crate) fn self_update_permitted(explicit: bool) -> Result<SelfUpdatePermissi
11051106}
11061107
11071108/// Performs all of a self-update: check policy, download, apply and exit.
1108- pub ( crate ) async fn self_update ( process : & Process ) -> Result < utils:: ExitCode > {
1109+ pub ( crate ) async fn self_update ( dl_cfg : & DownloadCfg < ' _ > ) -> Result < utils:: ExitCode > {
11091110 match self_update_permitted ( false ) ? {
11101111 SelfUpdatePermission :: HardFail => {
11111112 error ! ( "Unable to self-update. STOP" ) ;
@@ -1116,13 +1117,13 @@ pub(crate) async fn self_update(process: &Process) -> Result<utils::ExitCode> {
11161117 SelfUpdatePermission :: Permit => { }
11171118 }
11181119
1119- let setup_path = prepare_update ( process ) . await ?;
1120+ let setup_path = prepare_update ( dl_cfg ) . await ?;
11201121
11211122 if let Some ( setup_path) = & setup_path {
11221123 return run_update ( setup_path) ;
11231124 } else {
11241125 // Try again in case we emitted "tool `{}` is already installed" last time.
1125- install_proxies ( process) ?;
1126+ install_proxies ( dl_cfg . process ) ?;
11261127 }
11271128
11281129 Ok ( utils:: ExitCode ( 0 ) )
@@ -1167,7 +1168,7 @@ pub(crate) async fn update(cfg: &Cfg<'_>) -> Result<utils::ExitCode> {
11671168 Permit => { }
11681169 }
11691170
1170- match prepare_update ( cfg. process ) . await ? {
1171+ match prepare_update ( & DownloadCfg :: new ( cfg) ) . await ? {
11711172 Some ( setup_path) => {
11721173 let Some ( version) = get_and_parse_new_rustup_version ( & setup_path) else {
11731174 error ! ( "failed to get rustup version" ) ;
@@ -1220,8 +1221,8 @@ fn parse_new_rustup_version(version: String) -> String {
12201221 String :: from ( matched_version)
12211222}
12221223
1223- pub ( crate ) async fn prepare_update ( process : & Process ) -> Result < Option < PathBuf > > {
1224- let cargo_home = process. cargo_home ( ) ?;
1224+ pub ( crate ) async fn prepare_update ( dl_cfg : & DownloadCfg < ' _ > ) -> Result < Option < PathBuf > > {
1225+ let cargo_home = dl_cfg . process . cargo_home ( ) ?;
12251226 let rustup_path = cargo_home. join ( format ! ( "bin{MAIN_SEPARATOR}rustup{EXE_SUFFIX}" ) ) ;
12261227 let setup_path = cargo_home. join ( format ! ( "bin{MAIN_SEPARATOR}rustup-init{EXE_SUFFIX}" ) ) ;
12271228
@@ -1243,22 +1244,22 @@ pub(crate) async fn prepare_update(process: &Process) -> Result<Option<PathBuf>>
12431244 // If someone really wants to use another version, they still can enforce
12441245 // that using the environment variable RUSTUP_OVERRIDE_HOST_TRIPLE.
12451246 #[ cfg( windows) ]
1246- let triple = dist:: TargetTriple :: from_host ( process) . unwrap_or ( triple) ;
1247+ let triple = dist:: TargetTriple :: from_host ( dl_cfg . process ) . unwrap_or ( triple) ;
12471248
12481249 // Get update root.
1249- let update_root = update_root ( process) ;
1250+ let update_root = update_root ( dl_cfg . process ) ;
12501251
12511252 // Get current version
12521253 let current_version = env ! ( "CARGO_PKG_VERSION" ) ;
12531254
12541255 // Get available version
12551256 info ! ( "checking for self-update (current version: {current_version})" ) ;
1256- let available_version = match process. var_opt ( "RUSTUP_VERSION" ) ? {
1257+ let available_version = match dl_cfg . process . var_opt ( "RUSTUP_VERSION" ) ? {
12571258 Some ( ver) => {
12581259 info ! ( "`RUSTUP_VERSION` has been set to `{ver}`" ) ;
12591260 ver
12601261 }
1261- None => get_available_rustup_version ( process ) . await ?,
1262+ None => get_available_rustup_version ( dl_cfg ) . await ?,
12621263 } ;
12631264
12641265 // If up-to-date
@@ -1274,16 +1275,23 @@ pub(crate) async fn prepare_update(process: &Process) -> Result<Option<PathBuf>>
12741275
12751276 // Download new version
12761277 info ! ( "downloading self-update (new version: {available_version})" ) ;
1277- download_file ( & download_url, & setup_path, None , & |_| ( ) , process) . await ?;
1278+ download_file (
1279+ & download_url,
1280+ & setup_path,
1281+ None ,
1282+ & dl_cfg. notifier ,
1283+ dl_cfg. process ,
1284+ )
1285+ . await ?;
12781286
12791287 // Mark as executable
12801288 utils:: make_executable ( & setup_path) ?;
12811289
12821290 Ok ( Some ( setup_path) )
12831291}
12841292
1285- async fn get_available_rustup_version ( process : & Process ) -> Result < String > {
1286- let update_root = update_root ( process) ;
1293+ async fn get_available_rustup_version ( dl_cfg : & DownloadCfg < ' _ > ) -> Result < String > {
1294+ let update_root = update_root ( dl_cfg . process ) ;
12871295 let tempdir = tempfile:: Builder :: new ( )
12881296 . prefix ( "rustup-update" )
12891297 . tempdir ( )
@@ -1293,7 +1301,14 @@ async fn get_available_rustup_version(process: &Process) -> Result<String> {
12931301 let release_file_url = format ! ( "{update_root}/release-stable.toml" ) ;
12941302 let release_file_url = utils:: parse_url ( & release_file_url) ?;
12951303 let release_file = tempdir. path ( ) . join ( "release-stable.toml" ) ;
1296- download_file ( & release_file_url, & release_file, None , & |_| ( ) , process) . await ?;
1304+ download_file (
1305+ & release_file_url,
1306+ & release_file,
1307+ None ,
1308+ & dl_cfg. notifier ,
1309+ dl_cfg. process ,
1310+ )
1311+ . await ?;
12971312 let release_toml_str = utils:: read_file ( "rustup release" , & release_file) ?;
12981313 let release_toml = toml:: from_str :: < RustupManifest > ( & release_toml_str)
12991314 . context ( "unable to parse rustup release file" ) ?;
@@ -1341,13 +1356,13 @@ impl fmt::Display for SchemaVersion {
13411356}
13421357
13431358/// Returns whether an update was available
1344- pub ( crate ) async fn check_rustup_update ( process : & Process ) -> anyhow:: Result < bool > {
1345- let mut t = process. stdout ( ) ;
1359+ pub ( crate ) async fn check_rustup_update ( dl_cfg : & DownloadCfg < ' _ > ) -> anyhow:: Result < bool > {
1360+ let mut t = dl_cfg . process . stdout ( ) ;
13461361 // Get current rustup version
13471362 let current_version = env ! ( "CARGO_PKG_VERSION" ) ;
13481363
13491364 // Get available rustup version
1350- let available_version = get_available_rustup_version ( process ) . await ?;
1365+ let available_version = get_available_rustup_version ( dl_cfg ) . await ?;
13511366
13521367 let _ = t. attr ( Attr :: Bold ) ;
13531368 write ! ( t. lock( ) , "rustup - " ) ?;
0 commit comments