You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2017/05/22 16:12:13 UTC
[2/4] commons-compress git commit: simplify code a little
simplify code a little
Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/b1dcd19c
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/b1dcd19c
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/b1dcd19c
Branch: refs/heads/master
Commit: b1dcd19c2f87a57e4c4b96aebeb4a226f10af636
Parents: 83b60fb
Author: Stefan Bodewig <bo...@apache.org>
Authored: Mon May 22 15:21:54 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Mon May 22 15:21:54 2017 +0200
----------------------------------------------------------------------
.../archivers/zip/ZipArchiveOutputStream.java | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-compress/blob/b1dcd19c/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
index ac329b4..077344d 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
@@ -758,18 +758,19 @@ public class ZipArchiveOutputStream extends ArchiveOutputStream {
final Zip64ExtendedInformationExtraField z64 = getZip64Extra(entry.entry);
- // 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){
+ ZipEightByteInteger size, compressedSize;
+ if (phased) {
+ // sizes are already known
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;
+ compressedSize = size = new ZipEightByteInteger(entry.entry.getSize());
+ } else {
+ // just a placeholder, real data will be in data
+ // descriptor or inserted later via SeekableByteChannel
+ compressedSize = size = ZipEightByteInteger.ZERO;
}
z64.setSize(size);
z64.setCompressedSize(compressedSize);