geoip-lite
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -28,2 +28,7 @@ var fs = require('fs'), | ||
function onWatchEvent(event, changedFile) { | ||
// check to make sure changedFile is not null | ||
if (!changedFile) { | ||
return; | ||
} | ||
var filePath = path.join(directory, changedFile); | ||
@@ -30,0 +35,0 @@ |
{ | ||
"name" : "geoip-lite", | ||
"version" : "1.2.1", | ||
"version" : "1.2.2", | ||
"description" : "A light weight native JavaScript implementation of GeoIP API from MaxMind", | ||
@@ -24,3 +24,3 @@ "keywords" : ["geo", "geoip", "ip", "ipv4", "ipv6", "geolookup", "maxmind", "geolite"], | ||
"rimraf": "^2.5.2", | ||
"unzip": "^0.1.11" | ||
"yauzl": "^2.9.2" | ||
}, | ||
@@ -27,0 +27,0 @@ "config": { |
@@ -21,3 +21,3 @@ // fetches and converts maxmind lite databases | ||
var rimraf = require('rimraf').sync; | ||
var unzip = require('unzip'); | ||
var yauzl = require('yauzl'); | ||
var utils = require('../lib/utils'); | ||
@@ -164,16 +164,33 @@ | ||
process.stdout.write('Extracting ' + tmpFileName + ' ...'); | ||
fs.createReadStream(tmpFile) | ||
.pipe(unzip.Parse()) | ||
.on('entry', function(entry) { | ||
var fileName = path.basename(entry.path); | ||
var type = entry.type; // 'Directory' or 'File' | ||
if (type.toLowerCase() === 'file' && path.extname(fileName) === '.csv') { | ||
entry.pipe(fs.createWriteStream(path.join(tmpPath, fileName))); | ||
yauzl.open(tmpFile, {autoClose: true, lazyEntries: true}, function(err, zipfile) { | ||
if (err) { | ||
throw err; | ||
} | ||
zipfile.readEntry(); | ||
zipfile.on("entry", function(entry) { | ||
if (/\/$/.test(entry.fileName)) { | ||
// Directory file names end with '/'. | ||
// Note that entries for directories themselves are optional. | ||
// An entry's fileName implicitly requires its parent directories to exist. | ||
zipfile.readEntry(); | ||
} else { | ||
entry.autodrain(); | ||
// file entry | ||
zipfile.openReadStream(entry, function(err, readStream) { | ||
if (err) { | ||
throw err; | ||
} | ||
readStream.on("end", function() { | ||
zipfile.readEntry(); | ||
}); | ||
var filePath = entry.fileName.split("/"); | ||
// filePath will always have length >= 1, as split() always returns an array of at least one string | ||
var fileName = filePath[filePath.length - 1]; | ||
readStream.pipe(fs.createWriteStream(path.join(tmpPath, fileName))); | ||
}); | ||
} | ||
}) | ||
.on('finish', function() { | ||
}); | ||
zipfile.once("end", function() { | ||
cb(null, database); | ||
}); | ||
}); | ||
} | ||
@@ -180,0 +197,0 @@ } |
83811431
1065
+ Addedyauzl@^2.9.2
+ Addedbuffer-crc32@0.2.13(transitive)
+ Addedfd-slicer@1.1.0(transitive)
+ Addedpend@1.2.0(transitive)
+ Addedyauzl@2.10.0(transitive)
- Removedunzip@^0.1.11
- Removedbinary@0.3.0(transitive)
- Removedbuffers@0.1.1(transitive)
- Removedchainsaw@0.1.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedfstream@0.1.31(transitive)
- Removedgraceful-fs@3.0.12(transitive)
- Removedisarray@0.0.1(transitive)
- Removedmatch-stream@0.0.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removednatives@1.1.6(transitive)
- Removedover@0.0.5(transitive)
- Removedpullstream@0.4.1(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedslice-stream@1.0.0(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedtraverse@0.3.9(transitive)
- Removedunzip@0.1.11(transitive)