You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using JSZip to generate zip archives in the browser containing image files which are generated via a canvas.
It works great nearly all the time, but very rarely the zip archives generated contain a sequence of partially corrupted files. This produces unzip -t output like this:
...
testing: some_file.jpeg bad CRC b643aaa0 (should be 0b443b13)
file #24: bad zipfile offset (local header sig): 77528
file #25: bad zipfile offset (local header sig): 186714
file #26: bad zipfile offset (local header sig): 280620
file #27: bad zipfile offset (local header sig): 367435
file #28: bad zipfile offset (local header sig): 462321
file #29: bad zipfile offset (local header sig): 566764
file #30: bad zipfile offset (local header sig): 643411
file #31: bad zipfile offset (local header sig): 709539
file #32: bad zipfile offset (local header sig): 789450
file #33: bad zipfile offset (local header sig): 862629
file #34: bad zipfile offset (local header sig): 936287
testing: another_file.jpeg OK
...
In this case I'm able to extract the bad CRC 32 file with 7zip (which complains about the CRC but still extracts) and the file looks fine. However, the subsequent files with bad zipfile offset can't be extracted by 7zip.
I realize that debugging my specific file won't be possible here, but I'm wondering what could cause JSZip to produce a corrupted archive in the first place?
My zip generation code looks like this:
const jszip = await import('jszip');
const zipArchive = new jszip.default();
// generate deterministic zips
const entryOptions = {
date: new Date(1704067200000) // 2024-01-01
};
// Does not seem to get corrupted
zipArchive.file("metadata.json", JSON.stringify({
// various metadata fields
}), entryOptions);
// textFiles is an array of File objects created from strings.
// These do not seem to get corrupted
for (const textFile of textFiles) {
zipArchive.file(textFile.name, textFile, entryOptions);
}
// images is an array of JS File objects created from Blobs
for (const image of images) {
zipArchive.file(image.name, image, entryOptions);
}
The text was updated successfully, but these errors were encountered:
I'm using JSZip to generate zip archives in the browser containing image files which are generated via a canvas.
It works great nearly all the time, but very rarely the zip archives generated contain a sequence of partially corrupted files. This produces
unzip -t
output like this:In this case I'm able to extract the bad CRC 32 file with 7zip (which complains about the CRC but still extracts) and the file looks fine. However, the subsequent files with
bad zipfile offset
can't be extracted by 7zip.I realize that debugging my specific file won't be possible here, but I'm wondering what could cause JSZip to produce a corrupted archive in the first place?
My zip generation code looks like this:
The text was updated successfully, but these errors were encountered: