File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -310,14 +310,21 @@ fn execute_zip(
310
310
// filter hidden
311
311
{
312
312
let entry = entry?;
313
+ let relative_path = entry. path ( ) . strip_prefix ( & root_path) . unwrap ( ) ; // safe
314
+
313
315
if entry. path ( ) . is_file ( ) {
314
- let relative_path = entry. path ( ) . strip_prefix ( & root_path) . unwrap ( ) ; // safe
315
316
writer. start_file (
316
317
relative_path. to_string_lossy ( ) ,
317
318
zip:: write:: FileOptions :: default ( ) ,
318
319
) ?;
319
320
let bytes = file_util:: read_file ( entry. path ( ) ) ?;
320
321
writer. write_all ( & bytes) . map_err ( LangsError :: ZipWrite ) ?;
322
+ } else {
323
+ // java-langs expects directories to have their own entries
324
+ writer. start_file (
325
+ relative_path. join ( "" ) . to_string_lossy ( ) , // java-langs expects directory entries to have a trailing slash
326
+ zip:: write:: FileOptions :: default ( ) ,
327
+ ) ?;
321
328
}
322
329
}
323
330
writer. finish ( ) ?;
@@ -518,6 +525,16 @@ mod test {
518
525
. to_string_lossy( )
519
526
)
520
527
. is_err( ) ) ; // hidden files filtered
528
+ assert ! ( fz
529
+ . by_name(
530
+ & Path :: new( "part2" )
531
+ . join( "ex2" )
532
+ . join( "dir" )
533
+ . join( "subdir" )
534
+ . join( "" )
535
+ . to_string_lossy( ) ,
536
+ )
537
+ . is_ok( ) ) ; // directories have their own entries with trailing slashes
521
538
let mut file = fz
522
539
. by_name (
523
540
& Path :: new ( "part2" )
You can’t perform that action at this time.
0 commit comments