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

Decompress from stream #314

Closed
NobodyXu opened this issue Jun 13, 2022 · 6 comments · Fixed by #316
Closed

Decompress from stream #314

NobodyXu opened this issue Jun 13, 2022 · 6 comments · Fixed by #316

Comments

@NobodyXu
Copy link
Contributor

Here in cargo-binstall, we are forced to write the downloaded file first to the disk, then pass it to ZipArchiver whereas all the other algorithms we support (gzip, xzip and zstd) have a streaming interface that just accepts BufRead (and Read for convenience).

Is it possible for zip to have a streaming interface that takes BufRead?

@NobodyXu NobodyXu changed the title Stream based unzip interface? Decompress from stream Jun 13, 2022
@NobodyXu
Copy link
Contributor Author

@zamazan4ik Can we have this feature in zip?

@zamazan4ik
Copy link
Contributor

Yes, you can. But this library is in maintenance-only state. So if you want to implement it, the best idea is prepare a PR and send it here :) I will try to review and merge it.

@NobodyXu
Copy link
Contributor Author

I have zero knowledge on zip's codebase, but I will spend my time to understand and hopefully it won't be too complicated to add this feature.

@NobodyXu
Copy link
Contributor Author

I just realized that zip keeps its central directory at the end of the file, so it is possible to parse the local file header first and extract them, then parses the central directory and set the attributes of the files/dirs created.

Sounds feasible but it would be quite complex and I'd better create a new type specifically for this functionality.

@zamazan4ik Does that sound good to you? Is there anything I miss regarding zip format?

@zamazan4ik
Copy link
Contributor

@NobodyXu unfortunately, I am not the good person for asking questions about ZIP details :) @Plecra I guess you know much more details

@NobodyXu
Copy link
Contributor Author

Aha, I just realized that zip::read_zipfile_from_stream can be used to decompress from stream, but it has one problem:

It's missing unix_mode data which are crucial for my application.

Perhaps I can implement something atop it, or I can expose the central directory so that user can parse that themselves.

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