pR0Ps/zipstream-ng

Add support for generating parts of the zip

Opened this issue · 1 comments

pR0Ps commented

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.

Another requirement is that, because of how the 206 Partial Content works, each request is called separately. I should work completely independently of each other.