Skip to content

Commit 049d552

Browse files
committed
Extract self_update() from update_all_channels()
1 parent fa3f4b4 commit 049d552

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/cli/common.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,11 @@ fn show_channel_updates(
280280

281281
pub(crate) async fn update_all_channels(
282282
cfg: &Cfg<'_>,
283-
do_self_update: bool,
284283
force_update: bool,
285284
) -> Result<utils::ExitCode> {
286285
let toolchains = cfg.update_all_channels(force_update).await?;
287286
let has_update_error = toolchains.iter().any(|(_, r)| r.is_err());
288-
let mut exit_code = utils::ExitCode(if has_update_error { 1 } else { 0 });
287+
let exit_code = utils::ExitCode(if has_update_error { 1 } else { 0 });
289288

290289
if toolchains.is_empty() {
291290
info!("no updatable toolchains installed");
@@ -301,10 +300,6 @@ pub(crate) async fn update_all_channels(
301300
show_channel_updates(cfg, t)?;
302301
}
303302

304-
if do_self_update {
305-
exit_code &= self_update(cfg.process).await?;
306-
}
307-
308303
Ok(exit_code)
309304
}
310305

src/cli/rustup_mode.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,11 @@ async fn update(
995995
info!("the active toolchain `{toolchain}` has been installed");
996996
info!("it's active because: {reason}");
997997
} else {
998-
exit_code &= common::update_all_channels(cfg, self_update, opts.force).await?;
998+
exit_code &= common::update_all_channels(cfg, opts.force).await?;
999+
if self_update {
1000+
exit_code &= common::self_update(cfg.process).await?;
1001+
}
1002+
9991003
info!("cleaning up downloads & tmp directories");
10001004
utils::delete_dir_contents_following_links(&cfg.download_dir);
10011005
cfg.tmp_cx.clean();

0 commit comments

Comments
 (0)