Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permitting deflate level to be set #106

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

clarkevans
Copy link

This change adds a deflate_level parameter when adding a file, with the default value of 6. The hard-coded value of 9 has significant performance penalty and can be several times slower for only a minimal decrease in file size.

Copy link

@nhz2 nhz2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs added tests to ensure files written with these different options can be read correctly.

if f.method == Deflate
f._zio = Zlib.Writer(f._io, true)
if f.method == Deflate || !isnothing(deflate_level)
f._zio = Zlib.Writer(f._io, something(deflate_level, 6), true)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the f.method is being changed to Deflate here, this must also be recorded when writing the local and central directory record. See lines 630, and 424. Otherwise reading will fail.

Also, if the compression level is changed, the general purpose bit flag should also be changed.

See: https://github.com/JuliaIO/ZipArchives.jl/blob/9e8c54f19577ca2db5c8f89e80e0fb657b9f63fd/src/constants.jl#L7-L21

And https://github.com/madler/zipflow/blob/2bef2123ebe519c17b18d2d0c3c71065088de952/zipflow.c#L214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants