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 Feb 16, 2023
1 parent b93c355 commit 60ecfbc
Show file tree
Hide file tree
Showing 3 changed files with 20 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
9 changes: 9 additions & 0 deletions lib/zstream/zip/extra.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,13 @@ defmodule Zstream.Zip.Extra do
<<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 60ecfbc

Please sign in to comment.