repaired #130.
This commit is contained in:
parent
04533f89fd
commit
354c83f314
@ -61,8 +61,20 @@ public class ZipCompressor extends AbstractCompressor {
|
|||||||
|
|
||||||
if(input.getPath().isEmpty()) {
|
if(input.getPath().isEmpty()) {
|
||||||
entry = new ZipArchiveEntry(input.getName());
|
entry = new ZipArchiveEntry(input.getName());
|
||||||
|
|
||||||
|
//It's basically just
|
||||||
|
byte[] buff = new byte[(int)input.size()];
|
||||||
|
int len = input.getInputStream().read(buff);
|
||||||
|
Checksum sum = new CRC32();
|
||||||
|
sum.update(buff, 0, len);
|
||||||
|
entry.setCrc(sum.getValue());
|
||||||
|
|
||||||
entry.setMethod(ZipEntry.STORED);
|
entry.setMethod(ZipEntry.STORED);
|
||||||
entry.setSize(input.size());
|
entry.setSize(input.size());
|
||||||
|
|
||||||
|
((ZipArchiveOutputStream)arc).putArchiveEntry(entry);
|
||||||
|
|
||||||
|
arc.write(buff, 0, len);
|
||||||
} else {
|
} else {
|
||||||
Path file = input.getPath().get();
|
Path file = input.getPath().get();
|
||||||
entry = (ZipArchiveEntry) ((ZipArchiveOutputStream) arc).createArchiveEntry(file, input.getName());
|
entry = (ZipArchiveEntry) ((ZipArchiveOutputStream) arc).createArchiveEntry(file, input.getName());
|
||||||
@ -72,11 +84,11 @@ public class ZipCompressor extends AbstractCompressor {
|
|||||||
entry.setCompressedSize(Files.size(file));
|
entry.setCompressedSize(Files.size(file));
|
||||||
entry.setCrc(getCRC(file));
|
entry.setCrc(getCRC(file));
|
||||||
} else entry.setMethod(ZipEntry.DEFLATED);
|
} else entry.setMethod(ZipEntry.DEFLATED);
|
||||||
}
|
|
||||||
|
|
||||||
((ZipArchiveOutputStream)arc).putArchiveEntry(entry);
|
((ZipArchiveOutputStream)arc).putArchiveEntry(entry);
|
||||||
|
|
||||||
IOUtils.copy(fileInputStream, arc);
|
IOUtils.copy(fileInputStream, arc);
|
||||||
|
}
|
||||||
|
|
||||||
((ZipArchiveOutputStream)arc).closeArchiveEntry();
|
((ZipArchiveOutputStream)arc).closeArchiveEntry();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user