|
3 | 3 |
|
4 | 4 | use config::Config; |
5 | 5 | use manifest::{Component, Manifest, TargettedPackage}; |
6 | | -use dist::{download_and_check, DownloadCfg, TargetTriple}; |
| 6 | +use dist::{download_and_check, DownloadCfg, TargetTriple, DEFAULT_DIST_SERVER}; |
7 | 7 | use component::{Components, Transaction, TarGzPackage, Package}; |
8 | 8 | use temp; |
9 | 9 | use errors::*; |
@@ -122,13 +122,20 @@ impl Manifestation { |
122 | 122 | components_urls_and_hashes.push(c_u_h); |
123 | 123 | } |
124 | 124 |
|
| 125 | + let altered = temp_cfg.dist_server != DEFAULT_DIST_SERVER; |
| 126 | + |
125 | 127 | // Download component packages and validate hashes |
126 | 128 | let mut things_to_install: Vec<(Component, temp::File)> = Vec::new(); |
127 | 129 | for (component, url, hash) in components_urls_and_hashes { |
128 | 130 |
|
129 | 131 | notify_handler(Notification::DownloadingComponent(&component.pkg, |
130 | 132 | &self.target_triple, |
131 | 133 | &component.target)); |
| 134 | + let url = if altered { |
| 135 | + url.replace(DEFAULT_DIST_SERVER, temp_cfg.dist_server.as_str()) |
| 136 | + } else { |
| 137 | + url |
| 138 | + }; |
132 | 139 |
|
133 | 140 | // Download each package to temp file |
134 | 141 | let temp_file = try!(temp_cfg.new_file()); |
@@ -301,7 +308,8 @@ impl Manifestation { |
301 | 308 | return Err(format!("binary package was not provided for '{}'", |
302 | 309 | self.target_triple.to_string()).into()); |
303 | 310 | } |
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()); |
305 | 313 |
|
306 | 314 | notify_handler(Notification::DownloadingComponent("rust", |
307 | 315 | &self.target_triple, |
|
0 commit comments