@@ -257,16 +257,10 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
257257 . into_iter ( )
258258 . filter_map ( Result :: ok)
259259 . filter ( |entry| entry. path ( ) . is_file ( ) )
260- . map ( |entry| {
261- let entry_path = entry. into_path ( ) ;
262- let relative_path = entry_path. strip_prefix ( path) ?. to_owned ( ) ;
263- // Preserve the directory structure by including the directory name
264- let full_relative_path = Path :: new ( dir_name) . join ( relative_path) ;
265- Ok ( ( entry_path, full_relative_path) )
266- } )
260+ . map ( |entry| Ok ( entry. into_path ( ) ) )
267261 . collect :: < Result < Vec < _ > > > ( ) ?
268262 . into_iter ( )
269- . sorted_by ( |( _ , a ) , ( _ , b ) | a. cmp ( b) ) ;
263+ . sorted_by ( |a , b | a. cmp ( b) ) ;
270264
271265 // Need to set the last modified time to a fixed value to ensure consistent checksums
272266 // This is important as an optimization to avoid re-uploading the same chunks if they're already on the server
@@ -275,10 +269,12 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
275269 . compression_method ( zip:: CompressionMethod :: Stored )
276270 . last_modified_time ( DateTime :: default ( ) ) ;
277271
278- for ( entry_path, relative_path) in entries {
279- debug ! ( "Adding file to zip: {}" , relative_path. display( ) ) ;
272+ for entry_path in entries {
273+ let relative_path = entry_path. strip_prefix ( path) ?. to_owned ( ) ;
274+ let full_relative_path = Path :: new ( dir_name) . join ( relative_path) ;
275+ debug ! ( "Adding file to zip: {}" , full_relative_path. display( ) ) ;
280276
281- zip. start_file ( relative_path . to_string_lossy ( ) , options) ?;
277+ zip. start_file ( full_relative_path . to_string_lossy ( ) , options) ?;
282278 let file_byteview = ByteView :: open ( & entry_path) ?;
283279 zip. write_all ( file_byteview. as_slice ( ) ) ?;
284280 file_count += 1 ;
0 commit comments