Skip to content

Commit

Permalink
Fix zip_writefile of non dense arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
nhz2 committed Sep 1, 2024
1 parent 3822239 commit 55aa39b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ Base.write(w::ZipWriter, x::UInt8) = write(w, Ref(x))
Base.isopen(w::WriteOffsetTracker) = !w.bad
Base.close(w::WriteOffsetTracker) = nothing # this should never be called
Base.isreadable(w::WriteOffsetTracker) = false
Base.write(w::WriteOffsetTracker, x::UInt8) = write(w, Ref(x))

# All writes to the underlying IO go through this function.
# This enables ZipWriter when using zip_writefile to write to any IO that
Expand Down
9 changes: 9 additions & 0 deletions test/test_writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,13 @@ end
for T in (BigInt, UInt64, Int64)
@test r == zip_crc32(view(data, T(2):T(90)))
end
end

@testset "zip_writefile on non dense arrays" begin
out = IOBuffer()
ZipWriter(out) do w
zip_writefile(w, "data.txt", 0x01:0x0f)
end
r = ZipReader(take!(out))
@test zip_readentry(r, "data.txt") == 0x01:0x0f
end

0 comments on commit 55aa39b

Please sign in to comment.