fflate icon indicating copy to clipboard operation
fflate copied to clipboard

unzip does not support >65,535 files

Open neilrackett opened this issue 2 years ago • 3 comments

How to reproduce

If you try to unzip or unzipSync a zip file containing >65,535 files, only 65,535 files will be listed.

For example:

// Load zip file containing 100,000 files into ArrayBuffer
const zipArray = new Uint8Array(zipBuffer);
const files = unzipSync(zipArray);

console.log(Object.keys(files).length) // 65535

The problem

This issue occurs without any error messages, the number of files is simply truncated to 65,535.

neilrackett avatar Jul 04 '22 14:07 neilrackett

Could you provide a sample file (or how to generate one) so I can reproduce this?

101arrowz avatar Jul 04 '22 19:07 101arrowz

No problem: here's a zip file containing 70,000 sequentially named text files I created using a simple node script, then zipped using tar.

const fs = require('fs');
for (let i = 1; i <= 70000; i++) {
  fs.writeFileSync(`./files/file-${('000000' + i).substr(-6)}.txt`, 'x');
}
tar -a -c -f ../70000-files.zip *

70000-files.zip

neilrackett avatar Jul 04 '22 20:07 neilrackett

fflate isn't looking at the Zip64 end-of-central-directory record so it can only use the number of files given in the standard 16-bit EOCD record. This should be fixable, I'll look into it.

101arrowz avatar Jul 08 '22 17:07 101arrowz

Fixed in v0.7.4. Sorry for the long delay!

101arrowz avatar Oct 01 '22 00:10 101arrowz

Amazing, thank you!

neilrackett avatar Oct 04 '22 08:10 neilrackett