node-unzip
node-unzip copied to clipboard
node-unzip fails to parse a Zip file
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.
yauzl unzips this just fine.
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