ZipFile.jl
ZipFile.jl copied to clipboard
Error writing when multiple files has been added
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)