Skip to content

Commit 983ac43

Browse files
committed
changed refresh-course zip internals to match the previous implementation
1 parent 5e72d73 commit 983ac43

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tmc-langs/src/course_refresher.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff 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")

0 commit comments

Comments
 (0)