File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed
Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -249,9 +249,7 @@ fn normalize_directory(path: &Path) -> Result<TempFile> {
249249 . into_iter ( )
250250 . filter_map ( Result :: ok)
251251 . filter ( |entry| entry. path ( ) . is_file ( ) )
252- . map ( |entry| Ok ( entry. into_path ( ) ) )
253- . collect :: < Result < Vec < _ > > > ( ) ?
254- . into_iter ( )
252+ . map ( |entry| entry. into_path ( ) )
255253 . sorted_by ( |a, b| a. cmp ( b) ) ;
256254
257255 // Need to set the last modified time to a fixed value to ensure consistent checksums
@@ -401,3 +399,27 @@ fn poll_assemble(
401399
402400 Ok ( ( ) )
403401}
402+
403+ #[ cfg( test) ]
404+ mod tests {
405+ use super :: * ;
406+ use std:: fs;
407+ use zip:: ZipArchive ;
408+
409+ #[ test]
410+ fn test_normalize_directory_preserves_top_level_directory_name ( ) -> Result < ( ) > {
411+ let temp_dir = crate :: utils:: fs:: TempDir :: create ( ) ?;
412+ let test_dir = temp_dir. path ( ) . join ( "MyApp.xcarchive" ) ;
413+ fs:: create_dir_all ( & test_dir. join ( "Products" ) ) ?;
414+ fs:: write ( test_dir. join ( "Products" ) . join ( "app.txt" ) , "test content" ) ?;
415+
416+ let result_zip = normalize_directory ( & test_dir) ?;
417+ let zip_file = fs:: File :: open ( result_zip. path ( ) ) ?;
418+ let mut archive = ZipArchive :: new ( zip_file) ?;
419+ let file = archive. by_index ( 0 ) ?;
420+ let file_path = file. name ( ) ;
421+
422+ assert_eq ! ( file_path, "MyApp.xcarchive/Products/app.txt" ) ;
423+ Ok ( ( ) )
424+ }
425+ }
You can’t perform that action at this time.
0 commit comments