You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Frotty (Jira)" <ji...@apache.org> on 2020/06/07 10:27:00 UTC
[jira] [Updated] (COMPRESS-537) SevenZipOutputFile with DEFLATE
compression is incorrectly decompressed
[ https://issues.apache.org/jira/browse/COMPRESS-537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Frotty updated COMPRESS-537:
----------------------------
Description:
I create a 7zip archive and then load files from it. Using LZMA or BZIP2 works, but when I change it to DEFLATE the files aren't loaded correctly, parts of them are missing.
Example kotlin code:
{code:java}
public fun test() {
// SAVE
val target = File("target.7z")
val sevenZOutput = SevenZOutputFile(target)
sevenZOutput.setContentCompression(SevenZMethod.DEFLATE)
val file = File("roxpack.atlas")
val entry = sevenZOutput.createArchiveEntry(file, "roxpack.atlas")
sevenZOutput.putArchiveEntry(entry)
sevenZOutput.write(Files.readAllBytes(file.toPath()))
sevenZOutput.closeArchiveEntry()
sevenZOutput.close()
// LOAD
val s7f = SevenZFile(target)
s7f.use {
var nextEntry = it.nextEntry
do {
if (nextEntry.name == entry.name) {
val content = ByteArray(nextEntry.size.toInt())
s7f.read(content)
// with DEFLATE content array contains only 0's at the end, content string is cut off
println(String(content))
return
}
nextEntry = it.nextEntry
} while (nextEntry != null)
}
}
{code}
When I extract the file using 7zip GUI tool, the file is intact, so the problem lies within the decompression. And again, this all works fine with LZMA and BZIP2.
was:
I create a 7zip archive and then load files from it. Using LZMA or BZIP2 works, but when I change it to DEFLATE the files aren't loaded correctly, parts of them are missing.
Example kotlin code:
{code:java}
public fun test() {
// SAVE
val target = File("target.7z")
val sevenZOutput = SevenZOutputFile(target)
sevenZOutput.setContentCompression(SevenZMethod.DEFLATE)
val file = File("roxpack.atlas")
val entry = sevenZOutput.createArchiveEntry(file, "roxpack.atlas")
sevenZOutput.putArchiveEntry(entry)
sevenZOutput.write(Files.readAllBytes(file.toPath()))
sevenZOutput.closeArchiveEntry()
sevenZOutput.close()
// LOAD
val s7f = SevenZFile(target)
s7f.use {
var nextEntry = it.nextEntry
do {
if (nextEntry.name == entry.name) {
val content = ByteArray(nextEntry.size.toInt())
s7f.read(content)
// with DEFLATE content array contains only 0's at the end, content string is cut off
println(String(content))
return
}
nextEntry = it.nextEntry
} while (nextEntry != null)
}
}
{code}
When I extract the file using 7zip GUI tool, the file is intact, so the problem lies within the decompression.
> SevenZipOutputFile with DEFLATE compression is incorrectly decompressed
> -----------------------------------------------------------------------
>
> Key: COMPRESS-537
> URL: https://issues.apache.org/jira/browse/COMPRESS-537
> Project: Commons Compress
> Issue Type: Bug
> Affects Versions: 1.20
> Reporter: Frotty
> Priority: Major
> Attachments: roxpack.atlas
>
>
> I create a 7zip archive and then load files from it. Using LZMA or BZIP2 works, but when I change it to DEFLATE the files aren't loaded correctly, parts of them are missing.
> Example kotlin code:
>
> {code:java}
> public fun test() {
> // SAVE
> val target = File("target.7z")
> val sevenZOutput = SevenZOutputFile(target)
> sevenZOutput.setContentCompression(SevenZMethod.DEFLATE)
> val file = File("roxpack.atlas")
> val entry = sevenZOutput.createArchiveEntry(file, "roxpack.atlas")
> sevenZOutput.putArchiveEntry(entry)
> sevenZOutput.write(Files.readAllBytes(file.toPath()))
> sevenZOutput.closeArchiveEntry()
> sevenZOutput.close()
> // LOAD
> val s7f = SevenZFile(target)
> s7f.use {
> var nextEntry = it.nextEntry
> do {
> if (nextEntry.name == entry.name) {
> val content = ByteArray(nextEntry.size.toInt())
> s7f.read(content)
> // with DEFLATE content array contains only 0's at the end, content string is cut off
> println(String(content))
> return
> }
> nextEntry = it.nextEntry
> } while (nextEntry != null)
> }
> }
> {code}
> When I extract the file using 7zip GUI tool, the file is intact, so the problem lies within the decompression. And again, this all works fine with LZMA and BZIP2.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)