Skip to content

Commit dac7225

Browse files
committed
dist: avoid recomputing dist root URL
1 parent 0e5b936 commit dac7225

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ impl<'a> Cfg<'a> {
944944

945945
/// The root path of the release server, without the `/dist` suffix.
946946
/// By default, it points to [`dist::DEFAULT_DIST_SERVER`].
947-
pub(crate) fn dist_root_server(process: &Process) -> Result<String> {
947+
fn dist_root_server(process: &Process) -> Result<String> {
948948
if let Some(s) = process.var_opt("RUSTUP_DIST_SERVER")? {
949949
trace!("`RUSTUP_DIST_SERVER` has been set to `{s}`");
950950
return Ok(s);

src/dist/download.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use tracing::{debug, info, warn};
1212
use url::Url;
1313

1414
use super::{Channel, DEFAULT_DIST_SERVER, ToolchainDesc, temp};
15-
use crate::config::{Cfg, dist_root_server};
15+
use crate::config::Cfg;
1616
use crate::dist::manifest::Manifest;
1717
use crate::download::{download_file, download_file_with_resume};
1818
use crate::errors::RustupError;
@@ -138,11 +138,11 @@ impl<'a> DownloadCfg<'a> {
138138

139139
pub(crate) async fn dl_v2_manifest(
140140
&self,
141-
dist_root: &str,
142141
update_hash: Option<&Path>,
143142
toolchain: &ToolchainDesc,
143+
cfg: &Cfg<'_>,
144144
) -> Result<Option<(Manifest, String)>> {
145-
let manifest_url = toolchain.manifest_v2_url(dist_root, self.process);
145+
let manifest_url = toolchain.manifest_v2_url(&cfg.dist_root_url, self.process);
146146
match self
147147
.download_and_check(&manifest_url, update_hash, None, ".toml")
148148
.await
@@ -168,8 +168,7 @@ impl<'a> DownloadCfg<'a> {
168168
// Manifest checksum mismatched.
169169
warn!("{err}");
170170

171-
let server = dist_root_server(self.process)?;
172-
if server == DEFAULT_DIST_SERVER {
171+
if cfg.dist_root_url.starts_with(DEFAULT_DIST_SERVER) {
173172
info!(
174173
"this is likely due to an ongoing update of the official release server, please try again later"
175174
);
@@ -178,7 +177,8 @@ impl<'a> DownloadCfg<'a> {
178177
);
179178
} else {
180179
info!(
181-
"this might indicate an issue with the third-party release server '{server}'"
180+
"this might indicate an issue with the third-party release server '{}'",
181+
cfg.dist_root_url
182182
);
183183
info!(
184184
"see <https://github.com/rust-lang/rustup/issues/3885> for more details"

src/dist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,6 @@ impl<'a> DistOptions<'a> {
10631063
match self
10641064
.dl_cfg
10651065
.dl_v2_manifest(
1066-
&self.cfg.dist_root_url,
10671066
// Even if manifest has not changed, we must continue to install requested components.
10681067
// So if components or targets is not empty, we skip passing `update_hash` so that
10691068
// we essentially degenerate to `rustup component add` / `rustup target add`
@@ -1073,6 +1072,7 @@ impl<'a> DistOptions<'a> {
10731072
None
10741073
},
10751074
self.toolchain,
1075+
self.cfg,
10761076
)
10771077
.await
10781078
{

src/toolchain/distributable.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,12 @@ impl<'a> DistributableToolchain<'a> {
519519
}
520520

521521
pub async fn show_dist_version(&self) -> anyhow::Result<Option<String>> {
522-
let dist_root = &self.toolchain.cfg.dist_root_url;
523-
let update_hash = self.toolchain.cfg.get_hash_file(&self.desc, false)?;
524-
let download_cfg = DownloadCfg::new(self.toolchain.cfg);
525-
526-
match download_cfg
527-
.dl_v2_manifest(dist_root, Some(&update_hash), &self.desc)
522+
match DownloadCfg::new(self.toolchain.cfg)
523+
.dl_v2_manifest(
524+
Some(&self.toolchain.cfg.get_hash_file(&self.desc, false)?),
525+
&self.desc,
526+
self.toolchain.cfg,
527+
)
528528
.await?
529529
{
530530
Some((manifest, _)) => Ok(Some(manifest.get_rust_version()?.to_string())),

0 commit comments

Comments
 (0)