Skip to content

Store method depends on seek #384

Closed
Closed

Description

@Dedme

Steps to reproduce

  1. use a non-seekable stream
  2. attempt to store data in it. - using the store compression method
  3. it gets set as deflation method, but with 0% compression.

Expected behavior

Tell us what should happen
it should be stored and not encrypted.

Actual behavior

Tell us what happens instead
it gets run through the compression algorithm, albeit with no compression.

Version of SharpZipLib

1.2.0

Obtained from (only keep the relevant lines)

  • Package installed using NuGet (via dotnet add)

we have noticed at least some performance impact from not just copying the data, i am returning the zip on the fly from a web api as a stream, this means i cannot have a seekable stream.
i am zipping several large (40MB+) pdf and tiff images, that only slow down the compression, in the previous api we used DotNetZip and it worked fine and fast.
it took my some time via digging through your code and debugging what a 'can patch' stream is.
but is there any way of doing this as part of a write only stream? why does the stream need to be patchable?

Activity

  1. Dedme commented on Sep 12, 2019

    @Dedme
    Author

    on top is this library on dotnet core, the bottom is the old dotnetzip, on .net 4.7
    image

  2. Dedme commented on Sep 12, 2019

    @Dedme
    Author

    i went back to dotnetzip - when i started some months ago it didn't seem to be very core/.net Standard compliant, now it is.

  3. Numpsy commented on Sep 15, 2019

    @Numpsy
    Contributor

    The logic at

    // Can't patch entries so storing is not possible.

    looks to force the compression method to deflated when header information is unavailable, but i'm not sure if that's 'required' as such, or is just something it does to ensure that ZipInputStream can read the produced zip.

    Doesn't look like the behaviour is presently configurable, other than via populating all the header fields on the entry directly before adding it?

  4. piksel commented on Dec 31, 2019

    @piksel
    Member

    Yeah, this is because PKZIP 2 only supported descriptors for Deflate compression (descriptors come after the file data, which is necessary when we cannot seek in the stream and update the CRC and size after the data has been copied).

    I will make a PR that enables GeneralBitFlags.Descriptor for Stored compression, since compability with a 30 year old software version hardly seems justified.

  5. added
    enhancement
    zip
    on Jan 10, 2020
  6. piksel commented on Nov 22, 2020

    @piksel
    Member

    This is not possible to accomplish due to how the zip file format works and the comment about only supporting it for Deflate was meant to imply just that. See the InfoZip comment in #407

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

    enhancementwontfixzip

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions