Skip to content

Commit e0168e4

Browse files
committed
Extract self_update() from update_all_channels()
1 parent 49176ef commit e0168e4

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
@@ -930,7 +930,11 @@ async fn update(
930930
info!("the active toolchain `{toolchain}` has been installed");
931931
info!("it's active because: {reason}");
932932
} else {
933-
exit_code &= common::update_all_channels(cfg, self_update, opts.force).await?;
933+
exit_code &= common::update_all_channels(cfg, opts.force).await?;
934+
if self_update {
935+
exit_code &= common::self_update(cfg.process).await?;
936+
}
937+
934938
info!("cleaning up downloads & tmp directories");
935939
utils::delete_dir_contents_following_links(&cfg.download_dir);
936940
cfg.tmp_cx.clean();

0 commit comments

Comments
 (0)