@@ -152,31 +152,7 @@ impl Manifestation {
152152 let components = update
153153 . components_to_install
154154 . into_iter ( )
155- . filter_map ( |component| {
156- let package = match new_manifest. get_package ( component. short_name_in_manifest ( ) ) {
157- Ok ( p) => p,
158- Err ( e) => return Some ( Err ( e) ) ,
159- } ;
160-
161- let target_package = match package. get_target ( component. target . as_ref ( ) ) {
162- Ok ( tp) => tp,
163- Err ( e) => return Some ( Err ( e) ) ,
164- } ;
165-
166- match target_package. bins . is_empty ( ) {
167- // This package is not available, no files to download.
168- true => None ,
169- // We prefer the first format in the list, since the parsing of the
170- // manifest leaves us with the files/hash pairs in preference order.
171- false => Some ( Ok ( ComponentBinary {
172- status : download_cfg. status_for ( component. short_name ( & new_manifest) ) ,
173- component,
174- binary : & target_package. bins [ 0 ] ,
175- manifest : & new_manifest,
176- download_cfg,
177- } ) ) ,
178- }
179- } )
155+ . filter_map ( |component| ComponentBinary :: new ( component, & new_manifest, download_cfg) )
180156 . collect :: < Result < Vec < _ > > > ( ) ?;
181157
182158 const DEFAULT_CONCURRENT_DOWNLOADS : usize = 2 ;
@@ -647,6 +623,24 @@ struct ComponentBinary<'a> {
647623}
648624
649625impl < ' a > ComponentBinary < ' a > {
626+ fn new (
627+ component : Component ,
628+ manifest : & ' a Manifest ,
629+ download_cfg : & ' a DownloadCfg < ' a > ,
630+ ) -> Option < Result < Self > > {
631+ Some ( Ok ( ComponentBinary {
632+ binary : match manifest. binary ( & component) {
633+ Ok ( Some ( b) ) => b,
634+ Ok ( None ) => return None ,
635+ Err ( e) => return Some ( Err ( e) ) ,
636+ } ,
637+ status : download_cfg. status_for ( component. short_name ( manifest) ) ,
638+ component,
639+ manifest,
640+ download_cfg,
641+ } ) )
642+ }
643+
650644 async fn download ( self , max_retries : usize ) -> Result < ( Self , File ) > {
651645 use tokio_retry:: { RetryIf , strategy:: FixedInterval } ;
652646
0 commit comments