mrkline / piz-rs

Parallelized zip archive reading
zlib License
35 stars 12 forks source link

Issues opening .jar files #10

Open MichaelBrunn3r opened 1 year ago

MichaelBrunn3r commented 1 year ago

I'm trying to use this library to read images in parallel from a .jar file.

Listing files works great, but reading them or building a tree with as_tree does not work. To my knowledge .jar files are just .zip files, just like WordDocuments and ExcelSheets. I was able to open the .jar file using the zip crate.

Reading a file results in the error: InvalidArchive("Central directory entry doesn't match local file header")

let bytes = fs::read("Example.jar").unwrap();
let archive = ZipArchive::new(&bytes).unwrap();
let mut reader = archive.read(archive.entries()[0]).unwrap();
MichaelBrunn3r commented 1 year ago

It seems that all compressed_size and uncompressed_size are both 0 when parsing local file headers in .jar files. piz compares the local header with the metadata it received from the central directory entry. That seems to create the error. Disabling the feature check-local-metadata fixes this problem, as the check is never made. E.g. piz = { version = "0.5.1", default-features = false }

MichaelBrunn3r commented 1 year ago

However as_tree does not seem to work even with this fix. I get this error: Hierarchy("META-INF found before parent directories")

It seems META-INF was the first component and the tree did not contain a root node yet.