Skip to content

Commit bf04ae1

Browse files
committed
Extract self_update() from update_all_channels()
1 parent d14a7dc commit bf04ae1

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
@@ -991,7 +991,11 @@ async fn update(
991991
info!("the active toolchain `{toolchain}` has been installed");
992992
info!("it's active because: {reason}");
993993
} else {
994-
exit_code &= common::update_all_channels(cfg, self_update, opts.force).await?;
994+
exit_code &= common::update_all_channels(cfg, opts.force).await?;
995+
if self_update {
996+
exit_code &= common::self_update(cfg.process).await?;
997+
}
998+
995999
info!("cleaning up downloads & tmp directories");
9961000
utils::delete_dir_contents_following_links(&cfg.download_dir);
9971001
cfg.tmp_cx.clean();

0 commit comments

Comments
 (0)