@@ -37,6 +37,7 @@ use crate::term2;
37
37
use rustup:: dist:: dist:: { self , Profile , TargetTriple } ;
38
38
use rustup:: utils:: utils;
39
39
use rustup:: utils:: Notification ;
40
+ use rustup:: { Cfg , UpdateStatus } ;
40
41
use rustup:: { DUP_TOOLS , TOOLS } ;
41
42
use same_file:: Handle ;
42
43
use std:: env;
@@ -1379,7 +1380,7 @@ fn do_remove_from_path(methods: &[PathUpdateMethod]) -> Result<()> {
1379
1380
/// (and on windows this process will not be running to do it),
1380
1381
/// rustup-init is stored in `CARGO_HOME`/bin, and then deleted next
1381
1382
/// time rustup runs.
1382
- pub fn update ( ) -> Result < ( ) > {
1383
+ pub fn update ( cfg : & Cfg ) -> Result < ( ) > {
1383
1384
use common:: SelfUpdatePermission :: * ;
1384
1385
let update_permitted = if NEVER_SELF_UPDATE {
1385
1386
HardFail
@@ -1400,21 +1401,24 @@ pub fn update() -> Result<()> {
1400
1401
Permit => { }
1401
1402
}
1402
1403
1403
- let setup_path = prepare_update ( ) ?;
1404
- if let Some ( ref p ) = setup_path {
1405
- let version = match get_new_rustup_version ( p ) {
1406
- Some ( new_version) => parse_new_rustup_version ( new_version) ,
1407
- None => {
1408
- err ! ( "failed to get rustup version" ) ;
1409
- process:: exit ( 1 ) ;
1410
- }
1411
- } ;
1404
+ match prepare_update ( ) ? {
1405
+ Some ( setup_path ) => {
1406
+ let version = match get_new_rustup_version ( & setup_path ) {
1407
+ Some ( new_version) => parse_new_rustup_version ( new_version) ,
1408
+ None => {
1409
+ err ! ( "failed to get rustup version" ) ;
1410
+ process:: exit ( 1 ) ;
1411
+ }
1412
+ } ;
1412
1413
1413
- info ! ( "rustup updated successfully to {}" , version) ;
1414
- run_update ( p) ?;
1415
- } else {
1416
- // Try again in case we emitted "tool `{}` is already installed" last time.
1417
- install_proxies ( ) ?
1414
+ let _ = common:: show_channel_update ( cfg, "rustup" , Ok ( UpdateStatus :: Updated ( version) ) ) ;
1415
+ run_update ( & setup_path) ?;
1416
+ }
1417
+ None => {
1418
+ let _ = common:: show_channel_update ( cfg, "rustup" , Ok ( UpdateStatus :: Unchanged ) ) ;
1419
+ // Try again in case we emitted "tool `{}` is already installed" last time.
1420
+ install_proxies ( ) ?
1421
+ }
1418
1422
}
1419
1423
1420
1424
Ok ( ( ) )
0 commit comments