commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Bodewig (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COMPRESS-395) [Zip] Do not add data descriptor record when CRC and size values are known
Date Mon, 15 May 2017 15:32:04 GMT

    [ https://issues.apache.org/jira/browse/COMPRESS-395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16010712#comment-16010712
] 

Stefan Bodewig commented on COMPRESS-395:
-----------------------------------------

{{addRawArchiveEntry}} has been added fairly recently and we've likely not thought through
all possible combinations, thanks.

I wouldn't expect too much of a difference when we skipped the data descriptor, though.

> [Zip] Do not add data descriptor record when CRC and size values are known
> --------------------------------------------------------------------------
>
>                 Key: COMPRESS-395
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-395
>             Project: Commons Compress
>          Issue Type: Improvement
>          Components: Archivers
>            Reporter: Plamen Totev
>            Priority: Minor
>
> Hi,
> Currently {{ZipArchiveOutputStream}} will add data descriptor record when the output
do not provide random access. But if you add an entry using {{addRawArchiveEntry}} then the
CRC, compressed size and uncompressed size could be know and there is no need for data descriptor
record as those values could be set in the local file header. The current implementation does
both - it sets the correct value in the local file header and adds additional data descriptor
record. Here is the relevant code from {{ZipArchiveOutputStream#putArchiveEntry}}:
> {code:java}
>             // just a placeholder, real data will be in data
>             // descriptor or inserted later via SeekableByteChannel
>             ZipEightByteInteger size = ZipEightByteInteger.ZERO;
>             ZipEightByteInteger compressedSize = ZipEightByteInteger.ZERO;
>             if (phased){
>                 size = new ZipEightByteInteger(entry.entry.getSize());
>                 compressedSize = new ZipEightByteInteger(entry.entry.getCompressedSize());
>             } else if (entry.entry.getMethod() == STORED
>                     && entry.entry.getSize() != ArchiveEntry.SIZE_UNKNOWN) {
>                 // actually, we already know the sizes
>                 size = new ZipEightByteInteger(entry.entry.getSize());
>                 compressedSize = size;
>             }
>             z64.setSize(size);
>             z64.setCompressedSize(compressedSize);
> {code}
> Maybe {{ZipArchiveOutputStream}} could be improved to not add  data descriptor record
when the CRC and size values are known in advance.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message