Skip to content

Commit

Permalink
try to not include offset in local zip64 info
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthakumaran committed Jun 21, 2024
1 parent 5a55a55 commit 607f8a5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/zstream/protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Zstream.Protocol do

@comment "Created by Zstream"

def local_file_header(name, local_file_header_offset, options) do
def local_file_header(name, _local_file_header_offset, options) do
{crc32, c_size, size} =
if Keyword.fetch!(options, :data_descriptor) do
{0, 0, 0}
Expand All @@ -23,7 +23,7 @@ defmodule Zstream.Protocol do
zip64?(
options,
<<>>,
Extra.zip64_extended_info(size, c_size, local_file_header_offset)
Extra.local_zip64_extended_info(size, c_size)
)

[
Expand Down
5 changes: 5 additions & 0 deletions lib/zstream/zip/extra.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ defmodule Zstream.Zip.Extra do
<<0x0001::little-size(16), 28::little-size(16), size::little-size(64),
c_size::little-size(64), offset::little-size(64), 0::little-size(32)>>
end

def local_zip64_extended_info(size, c_size) do
<<0x0001::little-size(16), 16::little-size(16), size::little-size(64),
c_size::little-size(64)>>
end
end
9 changes: 9 additions & 0 deletions test/zstream_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ defmodule ZstreamTest do
end

test "zip with known size and crc" do
verify([
Zstream.entry("10.txt", ["123456789."],
coder: Zstream.Coder.Stored,
data_descriptor: false,
size: 10,
crc32: 3_692_204_934
)
])

verify([
Zstream.entry("kafka_uncompressed", file("kafan.txt"),
coder: Zstream.Coder.Stored,
Expand Down

0 comments on commit 607f8a5

Please sign in to comment.