@@ -158,9 +158,12 @@ impl Manifestation {
158158 // Download component packages and validate hashes
159159 let mut things_to_install = Vec :: new ( ) ;
160160 let mut things_downloaded = Vec :: new ( ) ;
161- let components = update. components_urls_and_hashes ( new_manifest) ?;
162- let components_len = components. len ( ) ;
161+ let components = update
162+ . components_urls_and_hashes ( new_manifest)
163+ . map ( |res| res. map ( |( component, binary) | ComponentBinary { component, binary } ) )
164+ . collect :: < Result < Vec < _ > > > ( ) ?;
163165
166+ let components_len = components. len ( ) ;
164167 const DEFAULT_CONCURRENT_DOWNLOADS : usize = 2 ;
165168 let concurrent_downloads = download_cfg
166169 . process
@@ -701,25 +704,26 @@ impl Update {
701704 fn components_urls_and_hashes < ' a > (
702705 & ' a self ,
703706 new_manifest : & ' a Manifest ,
704- ) -> Result < Vec < ComponentBinary < ' a > > > {
705- let mut components_urls_and_hashes = Vec :: new ( ) ;
706- for component in & self . components_to_install {
707- let package = new_manifest. get_package ( component. short_name_in_manifest ( ) ) ?;
708- let target_package = package. get_target ( component. target . as_ref ( ) ) ?;
707+ ) -> impl Iterator < Item = anyhow:: Result < ( & ' a Component , & ' a HashedBinary ) > > + ' a {
708+ self . components_to_install . iter ( ) . filter_map ( |component| {
709+ let package = match new_manifest. get_package ( component. short_name_in_manifest ( ) ) {
710+ Ok ( p) => p,
711+ Err ( e) => return Some ( Err ( e) ) ,
712+ } ;
713+
714+ let target_package = match package. get_target ( component. target . as_ref ( ) ) {
715+ Ok ( tp) => tp,
716+ Err ( e) => return Some ( Err ( e) ) ,
717+ } ;
709718
710- if target_package. bins . is_empty ( ) {
719+ match target_package. bins . is_empty ( ) {
711720 // This package is not available, no files to download.
712- continue ;
721+ true => None ,
722+ // We prefer the first format in the list, since the parsing of the
723+ // manifest leaves us with the files/hash pairs in preference order.
724+ false => Some ( Ok ( ( component, & target_package. bins [ 0 ] ) ) ) ,
713725 }
714- // We prefer the first format in the list, since the parsing of the
715- // manifest leaves us with the files/hash pairs in preference order.
716- components_urls_and_hashes. push ( ComponentBinary {
717- component,
718- binary : & target_package. bins [ 0 ] ,
719- } ) ;
720- }
721-
722- Ok ( components_urls_and_hashes)
726+ } )
723727 }
724728}
725729
0 commit comments