@@ -248,65 +248,15 @@ impl Manifestation {
248
248
249
249
// Install components
250
250
for ( component, format, installer_file) in things_to_install {
251
- // For historical reasons, the rust-installer component
252
- // names are not the same as the dist manifest component
253
- // names. Some are just the component name some are the
254
- // component name plus the target triple.
255
- let pkg_name = component. name_in_manifest ( ) ;
256
- let short_pkg_name = component. short_name_in_manifest ( ) ;
257
- let short_name = component. short_name ( new_manifest) ;
258
-
259
- ( download_cfg. notify_handler ) ( Notification :: InstallingComponent (
260
- & short_name,
261
- & self . target_triple ,
262
- component. target . as_ref ( ) ,
263
- ) ) ;
264
-
265
- let notification_converter = |notification : crate :: utils:: Notification < ' _ > | {
266
- ( download_cfg. notify_handler ) ( notification. into ( ) ) ;
267
- } ;
268
- let gz;
269
- let xz;
270
- let zst;
271
- let reader =
272
- utils:: FileReaderWithProgress :: new_file ( & installer_file, & notification_converter) ?;
273
- let package: & dyn Package = match format {
274
- CompressionKind :: GZip => {
275
- gz = TarGzPackage :: new (
276
- reader,
277
- tmp_cx,
278
- Some ( & notification_converter) ,
279
- download_cfg. process ,
280
- ) ?;
281
- & gz
282
- }
283
- CompressionKind :: XZ => {
284
- xz = TarXzPackage :: new (
285
- reader,
286
- tmp_cx,
287
- Some ( & notification_converter) ,
288
- download_cfg. process ,
289
- ) ?;
290
- & xz
291
- }
292
- CompressionKind :: ZStd => {
293
- zst = TarZStdPackage :: new (
294
- reader,
295
- tmp_cx,
296
- Some ( & notification_converter) ,
297
- download_cfg. process ,
298
- ) ?;
299
- & zst
300
- }
301
- } ;
302
-
303
- // If the package doesn't contain the component that the
304
- // manifest says it does then somebody must be playing a joke on us.
305
- if !package. contains ( & pkg_name, Some ( short_pkg_name) ) {
306
- return Err ( RustupError :: CorruptComponent ( short_name) . into ( ) ) ;
307
- }
308
-
309
- tx = package. install ( & self . installation , & pkg_name, Some ( short_pkg_name) , tx) ?;
251
+ tx = self . install_component (
252
+ component,
253
+ format,
254
+ installer_file,
255
+ tmp_cx,
256
+ download_cfg,
257
+ new_manifest,
258
+ tx,
259
+ ) ?;
310
260
}
311
261
312
262
// Install new distribution manifest
@@ -589,6 +539,77 @@ impl Manifestation {
589
539
590
540
Ok ( ( component, format, downloaded_file, hash) )
591
541
}
542
+
543
+ fn install_component < ' a > (
544
+ & self ,
545
+ component : Component ,
546
+ format : CompressionKind ,
547
+ installer_file : File ,
548
+ tmp_cx : & temp:: Context ,
549
+ download_cfg : & DownloadCfg < ' _ > ,
550
+ new_manifest : & Manifest ,
551
+ tx : Transaction < ' a > ,
552
+ ) -> Result < Transaction < ' a > > {
553
+ // For historical reasons, the rust-installer component
554
+ // names are not the same as the dist manifest component
555
+ // names. Some are just the component name some are the
556
+ // component name plus the target triple.
557
+ let pkg_name = component. name_in_manifest ( ) ;
558
+ let short_pkg_name = component. short_name_in_manifest ( ) ;
559
+ let short_name = component. short_name ( new_manifest) ;
560
+
561
+ ( download_cfg. notify_handler ) ( Notification :: InstallingComponent (
562
+ & short_name,
563
+ & self . target_triple ,
564
+ component. target . as_ref ( ) ,
565
+ ) ) ;
566
+
567
+ let notification_converter = |notification : crate :: utils:: Notification < ' _ > | {
568
+ ( download_cfg. notify_handler ) ( notification. into ( ) ) ;
569
+ } ;
570
+ let gz;
571
+ let xz;
572
+ let zst;
573
+ let reader =
574
+ utils:: FileReaderWithProgress :: new_file ( & installer_file, & notification_converter) ?;
575
+ let package: & dyn Package = match format {
576
+ CompressionKind :: GZip => {
577
+ gz = TarGzPackage :: new (
578
+ reader,
579
+ tmp_cx,
580
+ Some ( & notification_converter) ,
581
+ download_cfg. process ,
582
+ ) ?;
583
+ & gz
584
+ }
585
+ CompressionKind :: XZ => {
586
+ xz = TarXzPackage :: new (
587
+ reader,
588
+ tmp_cx,
589
+ Some ( & notification_converter) ,
590
+ download_cfg. process ,
591
+ ) ?;
592
+ & xz
593
+ }
594
+ CompressionKind :: ZStd => {
595
+ zst = TarZStdPackage :: new (
596
+ reader,
597
+ tmp_cx,
598
+ Some ( & notification_converter) ,
599
+ download_cfg. process ,
600
+ ) ?;
601
+ & zst
602
+ }
603
+ } ;
604
+
605
+ // If the package doesn't contain the component that the
606
+ // manifest says it does then somebody must be playing a joke on us.
607
+ if !package. contains ( & pkg_name, Some ( short_pkg_name) ) {
608
+ return Err ( RustupError :: CorruptComponent ( short_name) . into ( ) ) ;
609
+ }
610
+
611
+ package. install ( & self . installation , & pkg_name, Some ( short_pkg_name) , tx)
612
+ }
592
613
}
593
614
594
615
#[ derive( Debug ) ]
0 commit comments