@@ -1134,20 +1134,20 @@ async fn try_update_from_dist_(
11341134
11351135 // TODO: Add a notification about which manifest version is going to be used
11361136 info ! ( "syncing channel updates for {toolchain_str}" ) ;
1137- match dl_v2_manifest (
1138- download ,
1139- // Even if manifest has not changed, we must continue to install requested components.
1140- // So if components or targets is not empty, we skip passing `update_hash` so that
1141- // we essentially degenerate to `rustup component add` / `rustup target add`
1142- if components. is_empty ( ) && targets. is_empty ( ) {
1143- Some ( update_hash)
1144- } else {
1145- None
1146- } ,
1147- toolchain,
1148- cfg,
1149- )
1150- . await
1137+ match download
1138+ . dl_v2_manifest (
1139+ // Even if manifest has not changed, we must continue to install requested components.
1140+ // So if components or targets is not empty, we skip passing `update_hash` so that
1141+ // we essentially degenerate to `rustup component add` / `rustup target add`
1142+ if components. is_empty ( ) && targets. is_empty ( ) {
1143+ Some ( update_hash)
1144+ } else {
1145+ None
1146+ } ,
1147+ toolchain,
1148+ cfg,
1149+ )
1150+ . await
11511151 {
11521152 Ok ( Some ( ( m, hash) ) ) => {
11531153 match m. get_rust_version ( ) {
@@ -1243,7 +1243,7 @@ async fn try_update_from_dist_(
12431243 }
12441244
12451245 // If the v2 manifest is not found then try v1
1246- let manifest = match dl_v1_manifest ( & cfg. dist_root_url , download , toolchain) . await {
1246+ let manifest = match download . dl_v1_manifest ( & cfg. dist_root_url , toolchain) . await {
12471247 Ok ( m) => m,
12481248 Err ( err) => match err. downcast_ref :: < RustupError > ( ) {
12491249 Some ( RustupError :: ChecksumFailed { .. } ) => return Err ( err) ,
@@ -1279,84 +1279,6 @@ async fn try_update_from_dist_(
12791279 result
12801280}
12811281
1282- pub ( crate ) async fn dl_v2_manifest (
1283- download : & DownloadCfg < ' _ > ,
1284- update_hash : Option < & Path > ,
1285- toolchain : & ToolchainDesc ,
1286- cfg : & Cfg < ' _ > ,
1287- ) -> Result < Option < ( ManifestV2 , String ) > > {
1288- let manifest_url = toolchain. manifest_v2_url ( & cfg. dist_root_url , download. process ) ;
1289- match download
1290- . download_and_check ( & manifest_url, update_hash, None , ".toml" )
1291- . await
1292- {
1293- Ok ( manifest_dl) => {
1294- // Downloaded ok!
1295- let Some ( ( manifest_file, manifest_hash) ) = manifest_dl else {
1296- return Ok ( None ) ;
1297- } ;
1298- let manifest_str = utils:: read_file ( "manifest" , & manifest_file) ?;
1299- let manifest =
1300- ManifestV2 :: parse ( & manifest_str) . with_context ( || RustupError :: ParsingFile {
1301- name : "manifest" ,
1302- path : manifest_file. to_path_buf ( ) ,
1303- } ) ?;
1304-
1305- Ok ( Some ( ( manifest, manifest_hash) ) )
1306- }
1307- Err ( any) => {
1308- if let Some ( err @ RustupError :: ChecksumFailed { .. } ) =
1309- any. downcast_ref :: < RustupError > ( )
1310- {
1311- // Manifest checksum mismatched.
1312- warn ! ( "{err}" ) ;
1313-
1314- if cfg. dist_root_url . starts_with ( DEFAULT_DIST_SERVER ) {
1315- info ! (
1316- "this is likely due to an ongoing update of the official release server, please try again later"
1317- ) ;
1318- info ! ( "see <https://github.com/rust-lang/rustup/issues/3390> for more details" ) ;
1319- } else {
1320- info ! (
1321- "this might indicate an issue with the third-party release server '{}'" ,
1322- cfg. dist_root_url
1323- ) ;
1324- info ! ( "see <https://github.com/rust-lang/rustup/issues/3885> for more details" ) ;
1325- }
1326- }
1327- Err ( any)
1328- }
1329- }
1330- }
1331-
1332- async fn dl_v1_manifest (
1333- dist_root : & str ,
1334- download : & DownloadCfg < ' _ > ,
1335- toolchain : & ToolchainDesc ,
1336- ) -> Result < Vec < String > > {
1337- let root_url = toolchain. package_dir ( dist_root) ;
1338-
1339- if let Channel :: Version ( ver) = & toolchain. channel {
1340- // This is an explicit version. In v1 there was no manifest,
1341- // you just know the file to download, so synthesize one.
1342- let installer_name = format ! ( "{}/rust-{}-{}.tar.gz" , root_url, ver, toolchain. target) ;
1343- return Ok ( vec ! [ installer_name] ) ;
1344- }
1345-
1346- let manifest_url = toolchain. manifest_v1_url ( dist_root, download. process ) ;
1347- let manifest_dl = download
1348- . download_and_check ( & manifest_url, None , None , "" )
1349- . await ?;
1350- let ( manifest_file, _) = manifest_dl. unwrap ( ) ;
1351- let manifest_str = utils:: read_file ( "manifest" , & manifest_file) ?;
1352- let urls = manifest_str
1353- . lines ( )
1354- . map ( |s| format ! ( "{root_url}/{s}" ) )
1355- . collect ( ) ;
1356-
1357- Ok ( urls)
1358- }
1359-
13601282fn date_from_manifest_date ( date_str : & str ) -> Option < NaiveDate > {
13611283 NaiveDate :: parse_from_str ( date_str, "%Y-%m-%d" ) . ok ( )
13621284}
0 commit comments