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

Remove unreliable warning when reading #69

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/reader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,16 @@ function parse_central_directory_headers!(central_dir_buffer::Vector{UInt8}, num
)
end
# Maybe num_entries was too small: See https://github.com/thejoshwolfe/yauzl/issues/60
# In that case just log a warning
if bytesavailable(io_b) ≥ 4
if readle(io_b, UInt32) == 0x02014b50
@warn "There may be some entries that are being ignored"
end
skip(io_b, -4)
end
# In that case ignore any potential extra entries.
# Logging a warning here is not part of the zip spec, and causes JET
# to complain.
# Commented out warning:
# if bytesavailable(io_b) ≥ 4
# if readle(io_b, UInt32) == 0x02014b50
# @warn "There may be some entries that are being ignored"
# end
# skip(io_b, -4)
# end

resize!(central_dir_buffer, position(io_b))
entries
Expand Down
3 changes: 2 additions & 1 deletion test/test_reader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ end
@test isempty(entries)
@test central_dir_offset == 0

# @test_logs (:warn,"There may be some entries that are being ignored")
io = IOBuffer([b"PK\x01\x02"; b"PK\x05\x06"; zeros(UInt8,2*4+4*2+2)])
@test_logs (:warn,"There may be some entries that are being ignored") entries, central_dir_buffer, central_dir_offset = ZipArchives.parse_central_directory(io)
entries, central_dir_buffer, central_dir_offset = ZipArchives.parse_central_directory(io)
@test isempty(entries)
@test central_dir_offset == 0
end
Expand Down
Loading