Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Discussion: support for non-seekable reading #37

Merged
merged 1 commit into from
Jun 16, 2018

Conversation

FauxFaux
Copy link
Contributor

I would like to read entries from an un-seekable stream, such as stdin.

This pull request implements this by providing a read_single function that returns the next entry in the stream, or None if we've found the Central Directory, indicating the end of the file.

Not all of the metadata is available, as it's not all stored in the local header. This code involves a bit of copy-paste, but not as much as I was expecting. It would be nice to restructure ZipFileData such that it had the "core" entries (the ones that are available in the local header, as I'm partially exposing as ZipEntry), and the extended entries separately.

In terms of API.. uh. Java has ZipInputstream, which has an awful API. An archive could provide an iterator over entries, for non-seekable readers?

for (entry, reader) in streaming_archive.iter() { ..

I also don't know what to do about discrepancies between the Central Directory and what the iterator has already returned, when using this API. Perhaps the read_single entry could return the contents of the Central Directory when it's encountered, to allow users to work out whether they've seen deleted, or otherwise invalid entries? An iterator could validate this at the end, and Err() or something.

zip64 is a mess, but it's currently not supported by the other code.

@mvdnes
Copy link
Collaborator

mvdnes commented Apr 28, 2017

Thank you for implementing this!
I am a bit busy at the moment, but will have a look at it soon. This would be a very nice feature to have.

@dherman
Copy link

dherman commented Oct 9, 2017

@mvdnes I would love to use this functionality to be able to unpack a zip file as I'm reading it from a reqwest response. Is there any way I can help to get this feature implemented?

@mvdnes mvdnes merged commit 0b57461 into zip-rs:master Jun 16, 2018
@mvdnes
Copy link
Collaborator

mvdnes commented Jun 16, 2018

I have incorporated some of your code into this, and it seems to work for a few examples.
Currently the central directory is ignored. That could be an improvement. Sorry for the long time this took!
If you have any improvements or ideas, they would be very welcome.

awaken1ng pushed a commit to awaken1ng/zip-rs that referenced this pull request Apr 27, 2024
…s/dependabot/fetch-metadata-2.1.0

ci(deps)(deps): bump dependabot/fetch-metadata from 2.0.0 to 2.1.0
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants