diff options
author | przemyslawpluta <przemekpluta@hotmail.com> | 2015-11-27 20:45:50 +0000 |
---|---|---|
committer | przemyslawpluta <przemekpluta@hotmail.com> | 2015-11-27 20:45:50 +0000 |
commit | d5e840a8c6b30ef36d5df203041366648fade442 (patch) | |
tree | 548e248975452be62e6dc0d1d3bf6168c8da3b2c /lib | |
parent | 102c420963b2e446eac19815e55b4987055d2ed7 (diff) | |
download | mongo-edu-d5e840a8c6b30ef36d5df203041366648fade442.zip |
fix unzip
Diffstat (limited to 'lib')
-rw-r--r-- | lib/videos.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/videos.js b/lib/videos.js index c2b323c..2431a53 100644 --- a/lib/videos.js +++ b/lib/videos.js @@ -14,7 +14,7 @@ var path = require('path'), request = require('request'), progress = require('request-progress'), colors = require('colors'), - unzip = require('unzip'), + extract = require('extract-zip'), rimraf = require('rimraf'), mv = require('mv'), _ = require('lodash'); @@ -102,14 +102,11 @@ var handleList = function handleList(list, tags) { return nextItem(currentList); } - unzipFile = fs.createReadStream(downloadPath + name).pipe(unzip.Extract({ path: downloadPath + path.basename(name, extname) })); - - unzipFile.on('error', function error() { - console.log('i'.red + ' Unable to unzip ' + name.red + ' try manually.'); - rimraf(downloadPath + name.replace('.zip', ''), function rf() { nextItem(currentList); }); - }); - - unzipFile.on('close', function close() { + unzipFile = extract(downloadPath + name, {dir: downloadPath + path.basename(name, extname)}, function out(err) { + if (err) { + console.log('i'.red + ' Unable to unzip ' + name.red + ' try manually.'); + return rimraf(downloadPath + name.replace('.zip', ''), function rf() { nextItem(currentList); }); + } console.log('i'.green + ' Done.' + left); cleanup(downloadPath + name, currentList); }); |