@@ -11,6 +11,7 @@ use console::style;
1111use itertools:: Itertools as _;
1212use log:: { debug, info, warn} ;
1313use objectstore_client:: { ClientBuilder , ExpirationPolicy , Usecase } ;
14+ use rayon:: prelude:: * ;
1415use secrecy:: ExposeSecret as _;
1516use serde_json:: Value ;
1617use sha2:: { Digest as _, Sha256 } ;
@@ -230,7 +231,7 @@ fn compute_sha256_hash(path: &Path) -> Result<String> {
230231 let mut file = std:: fs:: File :: open ( path)
231232 . with_context ( || format ! ( "Failed to open image for hashing: {}" , path. display( ) ) ) ?;
232233 let mut hasher = Sha256 :: new ( ) ;
233- let mut buffer = [ 0u8 ; 8192 ] ;
234+ let mut buffer = [ 0u8 ; 65536 ] ;
234235 loop {
235236 let bytes_read = file
236237 . read ( & mut buffer)
@@ -332,10 +333,17 @@ fn upload_images(
332333 let mut many_builder = session. many ( ) ;
333334 let mut manifest_entries = HashMap :: new ( ) ;
334335 let mut collisions: HashMap < String , Vec < String > > = HashMap :: new ( ) ;
335- let mut kept_paths: HashMap < String , String > = HashMap :: new ( ) ;
336- for image in images {
337- debug ! ( "Processing image: {}" , image. path. display( ) ) ;
336+ let mut kept_paths = HashMap :: new ( ) ;
338337
338+ let hashed_images: Vec < _ > = images
339+ . into_par_iter ( )
340+ . map ( |image| {
341+ let hash = compute_sha256_hash ( & image. path ) ?;
342+ Ok ( ( image, hash) )
343+ } )
344+ . collect :: < Result < Vec < _ > > > ( ) ?;
345+
346+ for ( image, hash) in hashed_images {
339347 let image_file_name = image
340348 . relative_path
341349 . file_name ( )
@@ -353,7 +361,6 @@ fn upload_images(
353361 continue ;
354362 }
355363
356- let hash = compute_sha256_hash ( & image. path ) ?;
357364 let file = runtime
358365 . block_on ( tokio:: fs:: File :: open ( & image. path ) )
359366 . with_context ( || {
0 commit comments