node-unzip icon indicating copy to clipboard operation
node-unzip copied to clipboard

node-unzip fails to parse a Zip file

Open herzi opened this issue 10 years ago • 2 comments

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.

herzi avatar Apr 04 '14 07:04 herzi

yauzl unzips this just fine.

andrewrk avatar Oct 16 '14 00:10 andrewrk

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

piotrromanowski avatar Mar 11 '15 17:03 piotrromanowski