Skip to content

Commit 9ef85bc

Browse files
committed
feat(config)!: return UpdateStatus from ensure_installed()
1 parent e17cfec commit 9ef85bc

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/config.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,8 @@ impl<'a> Cfg<'a> {
753753
} => {
754754
let toolchain = self
755755
.ensure_installed(toolchain, components, targets, profile)
756-
.await?;
756+
.await?
757+
.1;
757758
Ok((toolchain, reason))
758759
}
759760
},
@@ -768,7 +769,8 @@ impl<'a> Cfg<'a> {
768769
let reason = ActiveReason::Default;
769770
let toolchain = self
770771
.ensure_installed(toolchain_desc, vec![], vec![], None)
771-
.await?;
772+
.await?
773+
.1;
772774
Ok((toolchain, reason))
773775
}
774776
},
@@ -784,14 +786,14 @@ impl<'a> Cfg<'a> {
784786
components: Vec<String>,
785787
targets: Vec<String>,
786788
profile: Option<Profile>,
787-
) -> Result<Toolchain<'_>> {
789+
) -> Result<(UpdateStatus, Toolchain<'_>)> {
788790
let components: Vec<_> = components.iter().map(AsRef::as_ref).collect();
789791
let targets: Vec<_> = targets.iter().map(AsRef::as_ref).collect();
790792
let profile = match profile {
791793
Some(profile) => profile,
792794
None => self.get_profile()?,
793795
};
794-
let toolchain = match DistributableToolchain::new(self, toolchain.clone()) {
796+
let (status, toolchain) = match DistributableToolchain::new(self, toolchain.clone()) {
795797
Err(RustupError::ToolchainNotInstalled(_)) => {
796798
DistributableToolchain::install(
797799
self,
@@ -802,18 +804,18 @@ impl<'a> Cfg<'a> {
802804
false,
803805
)
804806
.await?
805-
.1
806807
}
807808
Ok(mut distributable) => {
808-
if !distributable.components_exist(&components, &targets)? {
809-
distributable.update(&components, &targets, profile).await?;
810-
}
811-
distributable
809+
let status = if !distributable.components_exist(&components, &targets)? {
810+
distributable.update(&components, &targets, profile).await?
811+
} else {
812+
UpdateStatus::Unchanged
813+
};
814+
(status, distributable)
812815
}
813816
Err(e) => return Err(e.into()),
814-
}
815-
.into();
816-
Ok(toolchain)
817+
};
818+
Ok((status, toolchain.into()))
817819
}
818820

819821
/// Get the configured default toolchain.

0 commit comments

Comments
 (0)