Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Commit

Permalink
🎨 Zip: Clone the entry ourselves, omitting the CRC-32
Browse files Browse the repository at this point in the history
  • Loading branch information
punkeel committed Apr 24, 2017
1 parent 483579d commit 0024fd7
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private void sanitizeFile(BleachSession session, ZipInputStream zipIn, ZipOutput
streamBuilder.close();
}

ZipEntry newEntry = new ZipEntry(entry);
ZipEntry newEntry = cloneEntry(entry);
newEntry.setCompressedSize(-1);
newEntry.setSize(out.size());
newEntry.setComment(newEntry.getComment() + " - DocBleach");
Expand All @@ -95,4 +95,25 @@ private void sanitizeFile(BleachSession session, ZipInputStream zipIn, ZipOutput
out.writeTo(zipOut);
out.close();
}

// Copies everything except size & CRC-32
private ZipEntry cloneEntry(ZipEntry entry) {
ZipEntry newEntry = new ZipEntry(entry.getName());

newEntry.setTime(entry.getTime());
if (entry.getCreationTime() != null) {
newEntry.setCreationTime(entry.getCreationTime());
}
if (entry.getLastModifiedTime() != null) {
newEntry.setLastModifiedTime(entry.getLastModifiedTime());
}
if (entry.getLastAccessTime() != null) {
newEntry.setLastAccessTime(entry.getLastAccessTime());
}
newEntry.setComment(entry.getComment());
newEntry.setExtra(entry.getExtra());
newEntry.setMethod(entry.getMethod());

return newEntry;
}
}

0 comments on commit 0024fd7

Please sign in to comment.