Skip to content

Commit 98b7286

Browse files
KnightKnight
authored andcommitted
rustup_dist::manifestation: Modify urls in manifest
1 parent b7e2a6e commit 98b7286

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/rustup-dist/src/manifestation.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use config::Config;
55
use manifest::{Component, Manifest, TargettedPackage};
6-
use dist::{download_and_check, DownloadCfg, TargetTriple};
6+
use dist::{download_and_check, DownloadCfg, TargetTriple, DEFAULT_DIST_SERVER};
77
use component::{Components, Transaction, TarGzPackage, Package};
88
use temp;
99
use errors::*;
@@ -122,13 +122,20 @@ impl Manifestation {
122122
components_urls_and_hashes.push(c_u_h);
123123
}
124124

125+
let altered = temp_cfg.dist_server != DEFAULT_DIST_SERVER;
126+
125127
// Download component packages and validate hashes
126128
let mut things_to_install: Vec<(Component, temp::File)> = Vec::new();
127129
for (component, url, hash) in components_urls_and_hashes {
128130

129131
notify_handler(Notification::DownloadingComponent(&component.pkg,
130132
&self.target_triple,
131133
&component.target));
134+
let url = if altered {
135+
url.replace(DEFAULT_DIST_SERVER, temp_cfg.dist_server.as_str())
136+
} else {
137+
url
138+
};
132139

133140
// Download each package to temp file
134141
let temp_file = try!(temp_cfg.new_file());
@@ -301,7 +308,8 @@ impl Manifestation {
301308
return Err(format!("binary package was not provided for '{}'",
302309
self.target_triple.to_string()).into());
303310
}
304-
let url = url.unwrap();
311+
// Only replace once. The cost is inexpensive.
312+
let url = url.unwrap().replace(DEFAULT_DIST_SERVER, temp_cfg.dist_server.as_str());
305313

306314
notify_handler(Notification::DownloadingComponent("rust",
307315
&self.target_triple,

0 commit comments

Comments
 (0)