101arrowz / fflate

High performance (de)compression in an 8kB package

Home Page:https://101arrowz.github.io/fflate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unzip error thrown when big file as compression type 9

Furnezz opened this issue · comments

How to reproduce

Use the "fflate.Unzip()" function with "fflate.AsyncUnzipInflate" to unzip a folder with a file that has a size >= 2GB (possibly lower, didn't find the lower threshold). The file was zipped on Windows 10 - 64bit and has a compression type 9.
I've created a StackBlitz to reproduce the error: https://stackblitz.com/edit/stackblitz-starters-frez7y?file=src%2Fapp%2Fapp%2Fapp.component.ts

The problem

Based on the README of fflate, type 9 compression seems to be included (found on section 4.4.5) but it sends the following error when trying to get the data of a file compressed with type 9: Error: unknown compression type 9 with directly following this one TypeError: ctr is not a constructor.

I need to be able to read the files present in the zip folder to extract preview data but if all files are big (size <= 4GB) and so compressed with type 9 I can't even get any data.

fflate does not support type 9 compression; the README's verbiage is admittedly a bit confusing here.

You can even use custom compression/decompression algorithms from other libraries, as long as they are defined in the ZIP spec (see section 4.4.5)

This is meant to say that you can register a decompressor for a format specified in 4.4.5 if you implement it or bring it in from a different library, not that fflate has support for those decompressors by default.

If you need to support compression type 9, you will likely need to implement it yourself, as it's a relatively uncommon format. This should be relatively doable given that compression type 9 (Deflate64) is almost the same as DEFLATE but with some extra bit lengths; you could probably use fflate's inflt function as a baseline.