We want to stream many files that might result in archive size greater than 2^32 bytes. Here is how the issue can be reproduced:
$ mkfile 10m 10m.pdf # generates 10Mb file on macOS
Zstream.zip([
Zstream.entry("test/825m.pdf", File.stream!("/tmp/source/825m.pdf", [], 512), coder: Zstream.Coder.Stored),
Zstream.entry("test/821m.pdf", File.stream!("/tmp/source/821m.pdf", [], 512), coder: Zstream.Coder.Stored),
Zstream.entry("test/820m.pdf", File.stream!("/tmp/source/820m.pdf", [], 512), coder: Zstream.Coder.Stored),
Zstream.entry("test/801m.pdf", File.stream!("/tmp/source/801m.pdf", [], 512), coder: Zstream.Coder.Stored),
Zstream.entry("test/800m.pdf", File.stream!("/tmp/source/800m.pdf", [], 512), coder: Zstream.Coder.Stored),
Zstream.entry("test/100m.pdf", File.stream!("/tmp/source/100m.pdf", [], 512), coder: Zstream.Coder.Stored),
Zstream.entry("test/50m.pdf", File.stream!("/tmp/source/50m.pdf", [], 512), coder: Zstream.Coder.Stored)
])
|> Stream.into(File.stream!("/tmp/archive.zip"))
|> Stream.run
$ zipinfo archive.zip
Archive: archive.zip
Zip file size: 4421845870 bytes, number of entries: 7
warning [archive.zip]: 4294967296 extra bytes at beginning or within zipfile
(attempting to process anyway)
-rw-r--r-- 5.2 fat 865075200 bl stor 22-Nov-29 09:30 test/825m.pdf
-rw-r--r-- 5.2 fat 860880896 bl stor 22-Nov-29 09:30 test/821m.pdf
-rw-r--r-- 5.2 fat 859832320 bl stor 22-Nov-29 09:30 test/820m.pdf
-rw-r--r-- 5.2 fat 839909376 bl stor 22-Nov-29 09:30 test/801m.pdf
-rw-r--r-- 5.2 fat 838860800 bl stor 22-Nov-29 09:30 test/800m.pdf
-rw-r--r-- 5.2 fat 104857600 bl stor 22-Nov-29 09:30 test/100m.pdf
-rw-r--r-- 5.2 fat 52428800 bl stor 22-Nov-29 09:30 test/50m.pdf
7 files, 4421844992 bytes uncompressed, 4421844992 bytes compressed: 0.0%
$ unzip archive.zip
Archive: archive.zip
Created by Zstream
warning [archive.zip]: 4294967296 extra bytes at beginning or within zipfile
(attempting to process anyway)
file #1: bad zipfile offset (local header sig): 4294967296
(attempting to re-compensate)
extracting: test/825m.pdf
extracting: test/821m.pdf
extracting: test/820m.pdf
extracting: test/801m.pdf
extracting: test/800m.pdf
extracting: test/100m.pdf
file #7: bad zipfile offset (local header sig): 74449256
(attempting to re-compensate)
extracting: test/50m.pdf
Something seems to be wrong with 64-bit offsets. Do you have an idea how it can be fixed?