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(
310310 // filter hidden
311311 {
312312 let entry = entry?;
313+ let relative_path = entry. path ( ) . strip_prefix ( & root_path) . unwrap ( ) ; // safe
314+
313315 if entry. path ( ) . is_file ( ) {
314- let relative_path = entry. path ( ) . strip_prefix ( & root_path) . unwrap ( ) ; // safe
315316 writer. start_file (
316317 relative_path. to_string_lossy ( ) ,
317318 zip:: write:: FileOptions :: default ( ) ,
318319 ) ?;
319320 let bytes = file_util:: read_file ( entry. path ( ) ) ?;
320321 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+ ) ?;
321328 }
322329 }
323330 writer. finish ( ) ?;
@@ -518,6 +525,16 @@ mod test {
518525 . to_string_lossy( )
519526 )
520527 . 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
521538 let mut file = fz
522539 . by_name (
523540 & Path :: new ( "part2" )
You can’t perform that action at this time.
0 commit comments