Skip to content

Commit dca11ff

Browse files
rbtcollinsdjc
authored andcommitted
Make update_extra async
1 parent b697553 commit dca11ff

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

src/cli/rustup_mode.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,13 @@ fn update(cfg: &mut Cfg, opts: UpdateOpts) -> Result<utils::ExitCode> {
832832
cfg,
833833
desc.clone(),
834834
) {
835-
Ok(mut d) => {
836-
d.update_extra(&components, &targets, profile, force, allow_downgrade)?
837-
}
835+
Ok(mut d) => utils::run_future(d.update_extra(
836+
&components,
837+
&targets,
838+
profile,
839+
force,
840+
allow_downgrade,
841+
))?,
838842
Err(RustupError::ToolchainNotInstalled(_)) => {
839843
crate::toolchain::distributable::DistributableToolchain::install(
840844
cfg,

src/config.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,13 @@ impl Cfg {
895895

896896
// Update toolchains and collect the results
897897
let channels = channels.map(|(desc, mut distributable)| {
898-
let st = distributable.update_extra(&[], &[], profile, force_update, false);
898+
let st = utils::run_future(distributable.update_extra(
899+
&[],
900+
&[],
901+
profile,
902+
force_update,
903+
false,
904+
));
899905

900906
if let Err(ref e) = st {
901907
(self.notify_handler)(Notification::NonFatalError(e));

src/toolchain/distributable.rs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,12 @@ impl<'a> DistributableToolchain<'a> {
378378
targets: &[&str],
379379
profile: Profile,
380380
) -> anyhow::Result<UpdateStatus> {
381-
self.update_extra(components, targets, profile, true, false)
381+
utils::run_future(self.update_extra(components, targets, profile, true, false))
382382
}
383383

384384
/// Update a toolchain with control over the channel behaviour
385385
#[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))]
386-
pub(crate) fn update_extra(
386+
pub(crate) async fn update_extra(
387387
&mut self,
388388
components: &[&str],
389389
targets: &[&str],
@@ -409,24 +409,23 @@ impl<'a> DistributableToolchain<'a> {
409409
let hash_path = self.cfg.get_hash_file(&self.desc, true)?;
410410
let update_hash = Some(&hash_path as &Path);
411411

412-
utils::run_future(
413-
InstallMethod::Dist {
414-
cfg: self.cfg,
415-
desc: &self.desc,
416-
profile,
417-
update_hash,
418-
dl_cfg: self
419-
.cfg
420-
.download_cfg(&|n| (self.cfg.notify_handler)(n.into())),
421-
force,
422-
allow_downgrade,
423-
exists: true,
424-
old_date_version,
425-
components,
426-
targets,
427-
}
428-
.install(),
429-
)
412+
InstallMethod::Dist {
413+
cfg: self.cfg,
414+
desc: &self.desc,
415+
profile,
416+
update_hash,
417+
dl_cfg: self
418+
.cfg
419+
.download_cfg(&|n| (self.cfg.notify_handler)(n.into())),
420+
force,
421+
allow_downgrade,
422+
exists: true,
423+
old_date_version,
424+
components,
425+
targets,
426+
}
427+
.install()
428+
.await
430429
}
431430

432431
pub fn recursion_error(&self, binary_lossy: String) -> Result<Infallible, anyhow::Error> {

0 commit comments

Comments
 (0)