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

Error writing when multiple files has been added #55

Open
sylvaticus opened this issue Jul 18, 2019 · 0 comments
Open

Error writing when multiple files has been added #55

sylvaticus opened this issue Jul 18, 2019 · 0 comments

Comments

@sylvaticus
Copy link

When creating a new zip file (Julia v1.1, ZipFile v0.8.3), an error will be issued on the first write operation when several files has been added to the zip:

zf = ZipFile.Writer("example.zip")
f1 = ZipFile.addfile(zf, "file1.txt", method=ZipFile.Deflate)
f2 = ZipFile.addfile(zf, "dir1/file2.txt", method=ZipFile.Deflate)
write(f1, "Hello world1!\n") # Error !
write(f1, "Hello world1 again!\n")
write(f2, "Hello world2!\n")
close(zf)

The error stack is:

julia> write(f1, "Hello world1!\n")
ERROR: Error in zlib deflate stream (-2).
Stacktrace:
 [1] write(::ZipFile.Zlib.Writer, ::Ptr{UInt8}, ::Int64) at /home/lobianco/.julia/packages/ZipFile/oD4uG/src/Zlib.jl:142
 [2] unsafe_write(::ZipFile.Zlib.Writer, ::Ptr{UInt8}, ::UInt64) at /home/lobianco/.julia/packages/ZipFile/oD4uG/src/Zlib.jl:156
 [3] unsafe_write(::ZipFile.WritableFile, ::Ptr{UInt8}, ::UInt64) at /home/lobianco/.julia/packages/ZipFile/oD4uG/src/ZipFile.jl:542
 [4] write(::ZipFile.WritableFile, ::String) at ./gcutils.jl:87
 [5] top-level scope at none:0

This instead works:

zf = ZipFile.Writer("example.zip")
f1 = ZipFile.addfile(zf, "file1.txt", method=ZipFile.Deflate)
write(f1, "Hello world1!\n")
write(f1, "Hello world1 again!\n")
f2 = ZipFile.addfile(zf, "dir1/file2.txt", method=ZipFile.Deflate)
write(f2, "Hello world2!\n")
close(zf) 
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

No branches or pull requests

1 participant