Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions lib/tunnel_binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var localTunnelConfig_ = require('./cfg/node-tunnel-config-v3-latest.json'),
urlParse = require('url'),
HttpsProxyAgent = require('https-proxy-agent'),
util = require('./util'),
AdmZip = require('adm-zip'),
StreamZip = require('node-stream-zip'),
fs = require('fs'),
path = require('path'),
os = require('os'),
Expand Down Expand Up @@ -138,23 +138,29 @@ function TunnelBinary(httpTunnelConfig, options) {
var destBinaryPath = path.join(destParentDir, destBinaryName);
// Reading and Unzipping binary zip File
console.log(`Extracting binary`);
try {
var zip = new AdmZip(binaryPath);
zip.extractAllTo(destParentDir, false);
fs.chmod(destBinaryPath, '0755', function() {
return fnCallback(destBinaryPath)
var zip = new StreamZip.async({ file: binaryPath });
zip
.extract(null, path.resolve(destParentDir))
.then(function() {
return zip.close();
})
.then(function() {
fs.chmod(destBinaryPath, '0755', function() {
return fnCallback(destBinaryPath);
});
})
.catch(function(e) {
zip.close().catch(function() {});
console.log('Error log ------> ', e);
logger.log(
conf['user'],
conf['key'],
{ filename: __filename },
conf,
'Got Error while unzip downloading binary' + e
);
self.retryBinaryDownload_(conf, destParentDir, retries, binaryPath, fnCallback);
});
} catch (e) {
console.log("Error log ------> ", e);
logger.log(
conf['user'],
conf['key'],
{ filename: __filename },
conf,
'Got Error while unzip downloading binary' + e
);
self.retryBinaryDownload_(conf, destParentDir, retries, binaryPath, fnCallback);
}
} else {
console.error('Got Error while downloading binary zip');
logger.log(
Expand Down
Loading