Skip to content
Snippets Groups Projects

zip archives: keep individual files compression type

Merged Denis Carikli requested to merge GNUtoo/mat2:master into master

While hardcoding the compression to zipfile.ZIP_DEFLATED works for most use cases of mat, being able to produce cleaned up uncompressed zip files is useful for content that cannot be compressed more.

In addition it also enables to use mat2 for reproducible builds of Android bootanimation files file that don't support compression.

Signed-off-by: Denis 'GNUtoo' Carikli GNUtoo@cyberdimension.org

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Author Contributor

    ChangeLog v1->v2:

    • I've added some tests
    • In _get_member_compression, I added the return None.
  • mentioned in issue #160 (closed)

  • Developer

    To enable the CI, do the following:

    In your fork, go to Settings -> CI / CD -> Expand next to Runners settings -> Enable shared Runners.

    Afterwards, retry the jobs or force-push your branch.

  • jvoisin enabled an automatic merge when the pipeline for e8970f1c succeeds

    enabled an automatic merge when the pipeline for e8970f1c succeeds

  • Looks good to me: it'll be merged once the CI is green :)

  • Denis Carikli approved this merge request

    approved this merge request

  • Denis Carikli added 1 commit

    added 1 commit

    • 1703ed6e - zip archives: keep individual files compression type

    Compare with previous version

  • Author Contributor

    I'm more used to the mailing list workflow so to find how to contribute I read the CONTRIBUTING.md which didn't mention these tests, though the code had traces of them, and the commands are in .gitlab-ci.yml.

    Anyway I've still two issues left to fix, but I don't know how to fix them:

    • Pylint has an error (https://0xacab.org/GNUtoo/mat2/-/jobs/233684): libmat2/archive.py:166:4: R0915: Too many statements (52/50) (too-many-statements).. As it's not in the code path that I touched, and that my commit broke that test, could it be because it increased the size of the classes?
    • The second issue I have is with mypy(https://0xacab.org/GNUtoo/mat2/-/jobs/233686): it has 2 errors:libmat2/archive.py:441: error: Item "TarInfo" of "Union[ZipInfo, TarInfo]" has no attribute "compress_type" and libmat2/archive.py:445: error: Item "TarInfo" of "Union[ZipInfo, TarInfo]" has no attribute "compress_type". Here I do understand the error well, but I don't know how to fix it either. Adding a compress_type attribute to Tar doesn't look like the right fix to me as we have several classes for Tar to handle the compression. Using a zipinfo.ZipInfo type in the function declarations doesn't work either as the type conflicts. My idea here was to have an opaque type (compression) that the class ZipInfo would handle. Do you have an idea how to best fix that?

    Denis.

  • merged

  • Please do send a merge request to document whatever you found unclear in the CONTRIBUTING.md file.

    As for the errors:

    • pylint is being annoying, I silenced it for this particular warnings
    • mypy is being dumb, and is unable to understand libmat2's inheritance tree, so we have to use assert isinstance(member, zipfile.ZipInfo) to tell it that the class ZipParser doesn't have anything to do with tar.

    Thanks for your contribution :hearts:

Please register or sign in to reply
Loading