EvanOxfeld / node-unzip

node.js cross-platform unzip using streams
MIT License
614 stars 343 forks source link

node-unzip fails to parse a Zip file #48

Open herzi opened 10 years ago

herzi commented 10 years ago

I downloaded the zip file from: http://geolite.maxmind.com/download/geoip/database/GeoLite2-City-CSV.zip

I wrote this script to extract it:

#!/usr/bin/env node

var fs = require('fs');
var unzip = require('unzip');

var reader = fs.createReadStream('GeoLite2-City-CSV.zip');
var parser = unzip.Parse();

reader.on('error', function (error) {
    throw error;
});

parser.on('error', function (error) {
    throw error;
});
parser.on('entry', function (entry) {
    console.log(entry.type, entry.path);
    entry.autodrain();
});

parser.on('close', function () {
    console.log('done');
});

reader.pipe(parser);

// vim:set sw=4 et:

Which yields these strange errors:

File GeoLite2-City-CSV_20140401/GeoLite2-City-Locations.csv
File GeoLite2-City-CSV_20140401/COPYRIGHT.txt
File GeoLite2-City-CSV_20140401/LICENSE.txt
File GeoLite2-City-CSV_20140401/LICENSE.txt
File GeoLite2-City-CSV_20140401/LICENSE.txt
File GeoLite2-City-CSV_20140401/LICENSE.txt
File GeoLite2-City-CSV_20140401/GeoLite2-City-Blocks.csv
File GeoLite2-City-CSV_20140401/GeoLite2-City-Blocks.csv
File GeoLite2-City-CSV_20140401/GeoLite2-City-Blocks.csv
File GeoLite2-City-CSV_20140401/GeoLite2-City-Blocks.csv
File GeoLite2-City-CSV_20140401/GeoLite2-City-Blocks.csv
File GeoLite2-City-CSV_20140401/GeoLite2-City-Blocks.csv
File GeoLite2-City-CSV_20140401/GeoLite2-City-Blocks.csv
File GeoLite2-City-CSV_20140401/GeoLite2-City-Blocks.csv

/Users/herzi/Documents/Workspace/geoip/unzip.js:14
    throw error;
          ^
Error: too many length or distance symbols
    at Zlib._binding.onerror (zlib.js:295:17)

It looks like parsing this file fails. OSX 10.9's unzip in the command line works fine.

andrewrk commented 10 years ago

yauzl unzips this just fine.

piotrromanowski commented 9 years ago

Has a fix been submitted for this issue yet? I'm running into the same problem as well as: Error: invalid code lengths set at Zlib._binding.onerror (zlib.js:361:17) Not sure what exactly is causing this issue since its intermittent