From 60ecfbcfb00c9bd44380ff1ba4f4aff836a125d7 Mon Sep 17 00:00:00 2001 From: Anantha Kumaran Date: Thu, 16 Feb 2023 23:57:46 +0530 Subject: [PATCH] try to not include offset in local zip64 info --- lib/zstream/protocol.ex | 4 ++-- lib/zstream/zip/extra.ex | 9 +++++++++ test/zstream_test.exs | 9 +++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/zstream/protocol.ex b/lib/zstream/protocol.ex index 48119ef..ace9312 100644 --- a/lib/zstream/protocol.ex +++ b/lib/zstream/protocol.ex @@ -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} @@ -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) ) [ diff --git a/lib/zstream/zip/extra.ex b/lib/zstream/zip/extra.ex index 50553b4..3a8da06 100644 --- a/lib/zstream/zip/extra.ex +++ b/lib/zstream/zip/extra.ex @@ -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)>>, + <>, + <> + ] + end end diff --git a/test/zstream_test.exs b/test/zstream_test.exs index 5283fa9..a365a0a 100644 --- a/test/zstream_test.exs +++ b/test/zstream_test.exs @@ -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,