You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ZipWriter compression level cannot be customised #3
The ZipWriter compression level looks like it could be theoretically customised, but any settings for it, from 2-9, fail with the following error:
java.lang.IllegalArgumentException: Invalid compression level: -5
at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.setLevel(ZipArchiveOutputStream.java:712)
at gov.loc.repository.bagit.writer.impl.ZipWriter.startBag(ZipWriter.java:70)
at gov.loc.repository.bagit.impl.AbstractBag.accept(AbstractBag.java:430)
at gov.loc.repository.bagit.writer.impl.ZipWriter.write(ZipWriter.java:158)
The error is due to the following call that uses whatever level the user sent in, and modifies it to be a negative number, which is always going to be invalid:
this.zipOut.setLevel(this.compressionLevel * -1);
Trying to set compressionLevel to be a negative number to fix this fails with the following error:
java.lang.RuntimeException: Valid compression levels are 0-9.
at gov.loc.repository.bagit.writer.impl.ZipWriter.setCompressionLevel(ZipWriter.java:55)
The reason that the default, 1, seems to work is that -1 is apparently a special value, although I am not sure what it represents.
Activity
ansell commentedon Feb 11, 2014
This code does not seem to have been modified since it was first added, and the only test for it uses the default, 1 as the parameter.
d8dd9ec#diff-17
Merge pull request LibraryOfCongress#3 from rvanheest-DANS-KNAW/EASY-…