Identify corrupted entries before reading their data #261
-
Hi, is it possible to identify which files are corrupted inside the zip before you start reading their data? I have a zip file that is causing issues when extracting (local file header not found), but I would like to know that at the time i check the contents of the zip, rather than when i'm already trying to read the data. I compared the entry information for all the contents of the zipfile, but they don't seem to have any obvious issues. The error is thrown on |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The local header of an entry in a zip file must begin with Lines 260 to 262 in a8f0189 This test cannot be run when listing entries because the Note however that you can abort the execution of const entries = await zipReader.getEntries();
const controller = new AbortController();
try {
const promiseEntryData = entries[0].getData(new zip.BlobWriter(), { signal: controller.signal });
controller.abort();
await promiseEntryData;
} catch (error) {
if (error.message != zip.ERR_ABORT) {
throw error;
}
} |
Beta Was this translation helpful? Give feedback.
The local header of an entry in a zip file must begin with
0x504b0304
(in big-endian). The error you mentioned is thrown when this value is not found (cf. chapter 4.3.7 in the spec).zip.js/lib/core/zip-reader.js
Lines 260 to 262 in a8f0189
This test cannot be run when listing entries because the
ZipReader#getEntries
method would run much slower, especially when retrieving the zip content with aHttpRangeReader
instance or when reading a zip file with hundreds of entries.Note however that you can abort the execution of
Entry#getData
if you want to t…