Skip to content

System.IO.Compression should store NoCompression entries without wrapping them in Deflate streams #26185

Description

@Marv51

Currently when a ZipArchive is created and an entry is added with the CompressionLevel set to "no-compression" the file inside the archive is still wrapped in a deflate stream. The deflate stream correctly does not to compress the file.

However, zip does natively support uncompressed files. The compression method "stored" is made for this.

To create OpenDocument format files (ods, odt etc.) it is required to store the mimetype file without wrapping it in any compression stream. They do this, so that the mimetype can always found at a specific offset.
This change should also be a tiny performance and archive size improvement.

I have attached a diff of the changes necessary to implement this. I've run the tests, however I've not yet been able to build corefx in a way that I can use with my app to validate the patch is working.
diff.zip

If this is something you think is possible to merge, I can spend more time on this to create a proper PR.

Activity

  1. stephentoub commented on May 21, 2018

    @stephentoub
    Member

    Sounds like a reasonable thing to do. @ianhays?

  2. ianhays commented on May 21, 2018

    @ianhays
    Contributor

    Totally reasonable, and not the first time I've seen this request either. I can't find the other one with a quick search, though.

    I can't think of any real circumstances in which removing the nocompression entry's deflate header would cause issues. For testing we should try a zip produced by the new codeset with windows' zip library, unix unzip, and 7zip. Also should probably add a unit test of some sort.

  3. MrX13415 commented on Nov 8, 2018

    @MrX13415

    Well. I basically need this right now. Anyone has a fork or so where this is working?

  4. danmoseley commented on Nov 8, 2018

    @danmoseley
    Contributor

    Sounds like @Marv51 has the code change, above. We would welcome a PR.

  5. Marv51 commented on Nov 8, 2018

    @Marv51
    ContributorAuthor
  6. MrX13415 commented on Nov 8, 2018

    @MrX13415

    Oh, very nice. Thank you. :)

  7. danmoseley commented on Nov 8, 2018

    @danmoseley
    Contributor

    Thanks @Marv51. Let us know if the documentation in this repo is insufficient.

  8. transferred this issue fromdotnet/corefxon Jan 31, 2020
  9. added this to the 3.0 milestone on Jan 31, 2020
  10. ghost locked as resolved and limited conversation to collaborators on Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-System.IO.CompressionenhancementProduct code improvement that does NOT require public API changes/additions

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions