Closed nicroto closed 10 years ago
I have seen the same thing. I note that this only fails if I use DEFLATE
compression; STORE
works fine.
Mine can be reproduced using the following code:
var fs = require('fs');
var zip = new require('node-zip')();
zip.file('icon128.png', fs.readFileSync('icon128.png', 'binary'), { binary: true });
fs.writeFileSync('test.zip', zip.generate({ compression: 'DEFLATE', type: 'base64' }), 'base64');
and this image in the same directory.
Maybe scanning for a common sequence of bytes between the two files would be illuminating?
Ok guys, after updating JSZip to the newest version (thanks to @dduponchel) seems like these issues have been solved (I reproduced shepheb and it works now).
First of all - awesome module.
The problem I have is with specific text data. I have isolated the scenario to a file that after zipping couldn't fully be unzipped.
This worked on Mac OS X 10.8.4 (there wasn't any problem), but this is no longer the case on 10.8.5 (where node-zip started producing corrupted zip on the same data).
I have made a reproducible sample with the data which can't be zipped properly.
To run it, copy the 2 files from this gist: https://gist.github.com/nicroto/6652540 like this:
sample ---bin -------zip-test ---resources -------data.txt
If you don't have node-zip globally installed, add a node_modules dir with the node-zip module in it (I guess npm install will work even without package.json).
Then navigate in the terminal to the bin dir and execute the following commands:
$ ./zip-test $ unzip test.zip
At this point search for an error in the terminal and diff the original file with the produced from unzip.
Regards, Nikolay Tsenkov