@@ -34,6 +34,7 @@ use crate::common::{self, Confirm};
3434use crate :: errors:: * ;
3535use crate :: markdown:: md;
3636use crate :: term2;
37+ use rustup:: { Cfg , UpdateStatus } ;
3738use rustup:: dist:: dist:: { self , Profile , TargetTriple } ;
3839use rustup:: utils:: utils;
3940use rustup:: utils:: Notification ;
@@ -1414,7 +1415,7 @@ fn do_remove_from_path(methods: &[PathUpdateMethod]) -> Result<()> {
14141415/// (and on windows this process will not be running to do it),
14151416/// rustup-init is stored in `CARGO_HOME`/bin, and then deleted next
14161417/// time rustup runs.
1417- pub fn update ( ) -> Result < ( ) > {
1418+ pub fn update ( cfg : & Cfg ) -> Result < ( ) > {
14181419 use common:: SelfUpdatePermission :: * ;
14191420 let update_permitted = if NEVER_SELF_UPDATE {
14201421 HardFail
@@ -1435,21 +1436,25 @@ pub fn update() -> Result<()> {
14351436 Permit => { }
14361437 }
14371438
1438- let setup_path = prepare_update ( ) ? ;
1439- if let Some ( ref p ) = setup_path {
1440- let version = match get_new_rustup_version ( p ) {
1441- Some ( new_version) => parse_new_rustup_version ( new_version) ,
1442- None => {
1443- err ! ( "failed to get rustup version" ) ;
1444- process:: exit ( 1 ) ;
1445- }
1446- } ;
1439+ match prepare_update ( ) {
1440+ Ok ( Some ( ref setup_path ) ) => {
1441+ let version = match get_new_rustup_version ( setup_path ) {
1442+ Some ( new_version) => parse_new_rustup_version ( new_version) ,
1443+ None => {
1444+ err ! ( "failed to get rustup version" ) ;
1445+ process:: exit ( 1 ) ;
1446+ }
1447+ } ;
14471448
1448- info ! ( "rustup updated successfully to {}" , version) ;
1449- run_update ( p) ?;
1450- } else {
1451- // Try again in case we emitted "tool `{}` is already installed" last time.
1452- install_proxies ( ) ?
1449+ let _ = common:: show_channel_update ( cfg, "rustup" , Ok ( UpdateStatus :: Updated ( version) ) ) ;
1450+ run_update ( setup_path) ?;
1451+ }
1452+ Ok ( None ) => {
1453+ let _ = common:: show_channel_update ( cfg, "rustup" , Ok ( UpdateStatus :: Unchanged ) ) ;
1454+ // Try again in case we emitted "tool `{}` is already installed" last time.
1455+ install_proxies ( ) ?
1456+ }
1457+ Err ( e) => common:: show_channel_update ( cfg, "rustup" , Err ( rustup:: ErrorKind :: Generic ( e. to_string ( ) ) . into ( ) ) ) ?,
14531458 }
14541459
14551460 Ok ( ( ) )
0 commit comments