fix: DetectZipUtil.zip, which can't handle non-files, not skips non-files
@@ -34,11 +34,16 @@ public class DetectZipUtil { //TODO: Add method for extracting without the wrapp
public static void zip(OutputStream stream, Map<String, Path> entries) throws IOException {
try (ZipOutputStream outputStream = new ZipOutputStream(stream)) {
for (Map.Entry<String, Path> entry : entries.entrySet()) {
- logger.info("Adding entry '{}' to zip as '{}'.", entry.getValue().toString(), entry.getKey());
+ // Files.readAllBytes requires a file
+ if (entry.getValue().toFile().isFile()) {
+ logger.debug("Adding entry '{}' to zip as '{}'.", entry.getValue().toString(), entry.getKey());
outputStream.putNextEntry(new ZipEntry(entry.getKey()));
byte[] bytes = Files.readAllBytes(entry.getValue());
outputStream.write(bytes, 0, bytes.length);
outputStream.closeEntry();
+ } else {
+ logger.trace("Non-file {} skipped", entry.getValue().toFile().getAbsolutePath());
+ }
}
}
}
