[Issue 1832] reading/writing an archive causes data loss; std.zip horribly broken

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 16 15:13:40 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=1832


Andrea Fontana <advmail at katamail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |advmail at katamail.com


--- Comment #1 from Andrea Fontana <advmail at katamail.com> 2013-11-16 15:13:36 PST ---
It seems it's a bug on build() function.

build() function assumes that all ArchiveEntry as expandedData to be
compressed.
So it cycle over elements and compress expandedData to compressedData.

If one of ArchiveEntry is just compressed and never expanded, expandedData will
be empty, and build() tries to compress empty data.

I've fixed it in this way:

For each element I check if compressedSize > 0. If true it means that we have
compressed data available, so we can copy it from buffer to field
.compressedData and we can skip compression for that element (usually it read
data from .expandedData, compress it and then copy to .compressedData).
Moreover we have not to check for expandedSize or CRC: we just have them from
header and we can't rely on expandedData field that is empty.

IMHO std.zip design it's not perfect. Every element copy compressData[] from
"global" data[] (so we have memory filled x 2). Moreover it's not useful to
store expandedData[] inside every element. It could be memory expensive (hey,
we're trying go compress it!), and probably it's just a copy of data we store
elsewhere. 

I think we should compress data on the fly, and don't store internally
expandedData. And that we just have to store compressedData one time.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list