@@ -4,7 +4,7 @@ var localTunnelConfig_ = require('./cfg/node-tunnel-config-v3-latest.json'),
44 urlParse = require ( 'url' ) ,
55 HttpsProxyAgent = require ( 'https-proxy-agent' ) ,
66 util = require ( './util' ) ,
7- unzip = require ( 'unzipper ' ) ,
7+ AdmZip = require ( 'adm-zip ' ) ,
88 fs = require ( 'fs' ) ,
99 path = require ( 'path' ) ,
1010 os = require ( 'os' ) ,
@@ -138,30 +138,23 @@ function TunnelBinary(httpTunnelConfig, options) {
138138 var destBinaryPath = path . join ( destParentDir , destBinaryName ) ;
139139 // Reading and Unzipping binary zip File
140140 console . log ( `Extracting binary` ) ;
141- fs . createReadStream ( binaryPath )
142- . pipe ( unzip . Extract ( { path : destParentDir } ) )
143- . on ( 'error' , function ( e ) {
144- console . log ( "Error log ------> " , e ) ;
145- logger . log (
146- conf [ 'user' ] ,
147- conf [ 'key' ] ,
148- { filename : __filename } ,
149- conf ,
150- 'Got Error while unzip downloading binary' + e
151- ) ;
152- self . retryBinaryDownload_ ( conf , destParentDir , retries , binaryPath , fnCallback ) ;
153- } )
154- . on ( 'close' , function ( ) {
155- // Throw error Error: spawn ETXTBSY sometime. As unzip completion not release binary file.
156- setTimeout ( function ( ) {
157- fs . rename ( unzipBinaryPath , destBinaryPath , function ( err ) {
158- // if (err) console.error('Got Error while rename binary zip', err);
159- fs . chmod ( destBinaryPath , '0755' , function ( ) {
160- return fnCallback ( destBinaryPath ) ;
161- } ) ;
162- } ) ;
163- } , 1000 ) ;
141+ try {
142+ var zip = new AdmZip ( binaryPath ) ;
143+ zip . extractAllTo ( destParentDir , true ) ;
144+ fs . chmod ( destBinaryPath , '0755' , function ( ) {
145+ return fnCallback ( destBinaryPath )
164146 } ) ;
147+ } catch ( e ) {
148+ console . log ( "Error log ------> " , e ) ;
149+ logger . log (
150+ conf [ 'user' ] ,
151+ conf [ 'key' ] ,
152+ { filename : __filename } ,
153+ conf ,
154+ 'Got Error while unzip downloading binary' + e
155+ ) ;
156+ self . retryBinaryDownload_ ( conf , destParentDir , retries , binaryPath , fnCallback ) ;
157+ }
165158 } else {
166159 console . error ( 'Got Error while downloading binary zip' ) ;
167160 logger . log (
0 commit comments