Skip to content

Commit 2eb794e

Browse files
rbtcollinsdjc
authored andcommitted
Make update async
1 parent 5baddf8 commit 2eb794e

File tree

1 file changed

+32
-33
lines changed

1 file changed

+32
-33
lines changed

src/cli/rustup_mode.rs

+32-33
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ pub async fn main() -> Result<utils::ExitCode> {
595595

596596
match subcmd {
597597
RustupSubcmd::DumpTestament => common::dump_testament(),
598-
RustupSubcmd::Install { opts } => update(cfg, opts),
598+
RustupSubcmd::Install { opts } => update(cfg, opts).await,
599599
RustupSubcmd::Uninstall { opts } => toolchain_remove(cfg, opts),
600600
RustupSubcmd::Show { verbose, subcmd } => handle_epipe(match subcmd {
601601
None => show(cfg, verbose),
@@ -611,18 +611,21 @@ pub async fn main() -> Result<utils::ExitCode> {
611611
no_self_update,
612612
force,
613613
force_non_host,
614-
} => update(
615-
cfg,
616-
UpdateOpts {
617-
toolchain,
618-
no_self_update,
619-
force,
620-
force_non_host,
621-
..UpdateOpts::default()
622-
},
623-
),
614+
} => {
615+
update(
616+
cfg,
617+
UpdateOpts {
618+
toolchain,
619+
no_self_update,
620+
force,
621+
force_non_host,
622+
..UpdateOpts::default()
623+
},
624+
)
625+
.await
626+
}
624627
RustupSubcmd::Toolchain { subcmd } => match subcmd {
625-
ToolchainSubcmd::Install { opts } => update(cfg, opts),
628+
ToolchainSubcmd::Install { opts } => update(cfg, opts).await,
626629
ToolchainSubcmd::List { verbose } => {
627630
handle_epipe(common::list_toolchains(cfg, verbose))
628631
}
@@ -791,7 +794,7 @@ async fn check_updates(cfg: &Cfg) -> Result<utils::ExitCode> {
791794
Ok(utils::ExitCode(0))
792795
}
793796

794-
fn update(cfg: &mut Cfg, opts: UpdateOpts) -> Result<utils::ExitCode> {
797+
async fn update(cfg: &mut Cfg, opts: UpdateOpts) -> Result<utils::ExitCode> {
795798
common::warn_if_host_is_emulated();
796799
let self_update_mode = cfg.get_self_update_mode()?;
797800
// Priority: no-self-update feature > self_update_mode > no-self-update args.
@@ -839,24 +842,20 @@ fn update(cfg: &mut Cfg, opts: UpdateOpts) -> Result<utils::ExitCode> {
839842
cfg,
840843
desc.clone(),
841844
) {
842-
Ok(mut d) => utils::run_future(d.update_extra(
843-
&components,
844-
&targets,
845-
profile,
846-
force,
847-
allow_downgrade,
848-
))?,
845+
Ok(mut d) => {
846+
d.update_extra(&components, &targets, profile, force, allow_downgrade)
847+
.await?
848+
}
849849
Err(RustupError::ToolchainNotInstalled(_)) => {
850-
utils::run_future(
851-
crate::toolchain::distributable::DistributableToolchain::install(
852-
cfg,
853-
&desc,
854-
&components,
855-
&targets,
856-
profile,
857-
force,
858-
),
859-
)?
850+
crate::toolchain::distributable::DistributableToolchain::install(
851+
cfg,
852+
&desc,
853+
&components,
854+
&targets,
855+
profile,
856+
force,
857+
)
858+
.await?
860859
.0
861860
}
862861
Err(e) => Err(e)?,
@@ -873,17 +872,17 @@ fn update(cfg: &mut Cfg, opts: UpdateOpts) -> Result<utils::ExitCode> {
873872
}
874873
}
875874
if self_update {
876-
utils::run_future(common::self_update(|| Ok(utils::ExitCode(0))))?;
875+
common::self_update(|| Ok(utils::ExitCode(0))).await?;
877876
}
878877
} else {
879-
utils::run_future(common::update_all_channels(cfg, self_update, opts.force))?;
878+
common::update_all_channels(cfg, self_update, opts.force).await?;
880879
info!("cleaning up downloads & tmp directories");
881880
utils::delete_dir_contents_following_links(&cfg.download_dir);
882881
cfg.tmp_cx.clean();
883882
}
884883

885884
if !self_update::NEVER_SELF_UPDATE && self_update_mode == SelfUpdateMode::CheckOnly {
886-
utils::run_future(check_rustup_update())?;
885+
check_rustup_update().await?;
887886
}
888887

889888
if self_update::NEVER_SELF_UPDATE {

0 commit comments

Comments
 (0)