Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to write_entry_stream while retaining valid local file headers #147

Open
oeed opened this issue Aug 4, 2024 · 1 comment
Open

Comments

@oeed
Copy link

oeed commented Aug 4, 2024

I am trying to generate ZIPs in a fairly low memory environment for files that can be quite large, so reading the entire contents and using write_entry_whole unfortunately isn't feasible. I have been using write_entry_stream, which does work well, but I've found Java based consumers reject files with invalid local headers with errors such as:

java.io.IOException: java.util.zip.DataFormatException: invalid stored block lengths

The docs do mention this:

The generated Local File Header will be invalid, with no compressed size, uncompressed size, and a null CRC. This might cause problems with the destination reader.

But I was wondering if there was some potential way around it, or a way to write chunks of data rather than in whole entries? Thank you for this crate!

@Majored
Copy link
Owner

Majored commented Sep 7, 2024

It sounds like the Java reader doesn't support files with data descriptors then, unfortunately.

Does the writer you're using implement Seek? One option I've been meaning to implement is double-writing, where you write a dummy local file header as you're going along, and then seek back and write the correct values in the LFH (and don't use a data description - acting as if it was written with write_entry_whole). Though obviously, this will require a bit of work so is not an immediate solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants