Bug 2137 – Data not compressed on fly when adding to zip archive

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2008-06-02T15:23:44Z
Last change time
2018-01-05T13:31:11Z
Assigned to
Walter Bright
Creator
David Simcha

Attachments

IDFilenameSummaryContent-TypeSize
269zip.diffDiffs to make std.zip compress on fly.text/plain2359

Comments

Comment #0 by dsimcha — 2008-06-02T15:23:44Z
The fact that, when an ArchiveMember is added via addMember() to a ZipArchive, the data in expandedData is not compressed on the fly, makes it very difficult to create large zip files without running out of memory. I have created a simple workaround by moving the following code from the build() method to the addMember() method: de.crc32 = std.zlib.crc32(0, cast(void[])de.expandedData); de.compressedData = cast(ubyte[])std.zlib.compress(cast(void[]))de.expandedData; de.compressedData = de.compressedData[2 .. de.compressedData.length - 4]; de.compressedSize = de.compressedData.length; de.expandedSize = de.expandedData.length; I also added the following to free the memory previously occupied by expandedData: de.expandedData=null; This is actually proving to be a significant issue for me, as I am attempting to use std.zip to archive large amounts of DNA sequence, which compresses extremely well, but won't fit in memory uncompressed.
Comment #1 by bugzilla — 2008-08-15T01:51:27Z
Could you please email me the diffs? Thanks!
Comment #2 by dsimcha — 2008-08-15T09:34:28Z
Created attachment 269 Diffs to make std.zip compress on fly.
Comment #3 by dsimcha — 2008-08-15T09:34:48Z
Here they are. Note that I had changed some style stuff to make the code more readable for me when I was trying to understand it, so a little of that may show up in the diffs. Also, I hadn't bothered to include the switch statement to get store mode to work because I didn't need it, but this should be trivial to put back.
Comment #4 by code — 2013-12-22T10:52:33Z
David, how about making a pull for this?
Comment #5 by razvan.nitu1305 — 2017-08-08T08:53:48Z
Comment #6 by github-bugzilla — 2017-08-10T13:37:44Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/6b151756108f57a1bc472ad121f27a38df2c80f0 Fix Issue 2137 - Data not compressed on fly when adding to zip archive https://github.com/dlang/phobos/commit/aa8c61f8a20cb1d0dd438bf0959453526663454e Merge pull request #5679 from RazvanN7/Issue_2137 Fix Issue 2137 - Data not compressed on fly when adding to zip archive merged-on-behalf-of: MetaLang <[email protected]>
Comment #7 by github-bugzilla — 2017-08-16T13:24:39Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/6b151756108f57a1bc472ad121f27a38df2c80f0 Fix Issue 2137 - Data not compressed on fly when adding to zip archive https://github.com/dlang/phobos/commit/aa8c61f8a20cb1d0dd438bf0959453526663454e Merge pull request #5679 from RazvanN7/Issue_2137
Comment #8 by github-bugzilla — 2018-01-05T13:31:11Z
Commits pushed to dmd-cxx at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/6b151756108f57a1bc472ad121f27a38df2c80f0 Fix Issue 2137 - Data not compressed on fly when adding to zip archive https://github.com/dlang/phobos/commit/aa8c61f8a20cb1d0dd438bf0959453526663454e Merge pull request #5679 from RazvanN7/Issue_2137