fix(toolchain): extract manifest fetching out of show_dist_version()

This commit is contained in:
Francisco Gouveia
2026-03-17 12:13:26 +00:00
committed by rami3l
parent 3a4ff160d1
commit dfd23d6cdd
2 changed files with 10 additions and 9 deletions

View File

@@ -46,7 +46,7 @@ use crate::{
dist::{
AutoInstallMode, DistOptions, PartialToolchainDesc, Profile, TargetTriple,
download::DownloadCfg,
manifest::{Component, ComponentStatus},
manifest::{Component, ComponentStatus, ManifestWithHash},
},
errors::RustupError,
install::{InstallMethod, UpdateStatus},
@@ -866,7 +866,12 @@ async fn check_updates(cfg: &Cfg<'_>, opts: CheckOpts) -> Result<ExitCode> {
async move {
let _permit = sem.acquire().await.unwrap();
let current_version = distributable.show_version()?;
let dist_version = distributable.show_dist_version().await?;
let dist_version = match distributable.fetch_dist_manifest().await? {
Some(ManifestWithHash { manifest, .. }) => {
Some(manifest.get_rust_version()?.to_string())
}
None => None,
};
let mut update_a = false;
let template = match (current_version, dist_version) {

View File

@@ -422,18 +422,14 @@ impl<'a> DistributableToolchain<'a> {
Ok(())
}
pub async fn show_dist_version(&self) -> anyhow::Result<Option<String>> {
match DownloadCfg::new(self.toolchain.cfg)
pub async fn fetch_dist_manifest(&self) -> anyhow::Result<Option<ManifestWithHash>> {
DownloadCfg::new(self.toolchain.cfg)
.dl_v2_manifest(
Some(&self.toolchain.cfg.get_hash_file(&self.desc, false)?),
&self.desc,
self.toolchain.cfg,
)
.await?
{
Some(ManifestWithHash { manifest, .. }) => Ok(Some(manifest.get_rust_version()?.to_string())),
None => Ok(None),
}
.await
}
pub fn show_version(&self) -> anyhow::Result<Option<String>> {