Skip to content

Add support for generating parts of the zip #19

Description

@pR0Ps

The use-case for this is being able to service range requests from a web endpoint. See #18

Should be possible seeing as the structure of the zip is known at build-time. The only issues I see at the moment are:

  • Will only work when no compression is used
  • File CRCs: The file must be completely read from the beginning to compute the CRC. This means that if you start streaming mid-file, you will have to read and throw away the data up until that point to compute the CRC. However, if the ZipStream object is re-used for all the requests, there is the possibility to cache the CRC of the file the first time it's accessed and cache it for future requests. Even more optimally, a pair of per-file offset read up to + partial CRC could be cached to resume CRC computation of partially-read files.
  • Header offsets: The absolute offset of each file header must be recorded so that it can be added to the end of central directory record. As long as there's no compression, this should be possible to compute for each file instead of storing the current stream position it like is currently done.

For exposing this functionality, create def stream(self, start=None, end=None) method that just calls finalize if no start/end are provided, otherwise generates the requested range.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions