@@ -14,6 +14,7 @@ import { HttpsProxyAgent } from 'https-proxy-agent';
14
14
import { promisify } from 'util' ;
15
15
import resolveConfig , { envToBool } from './resolve-config' ;
16
16
import debug from 'debug' ;
17
+ import dedent from 'dedent' ;
17
18
18
19
const log = debug ( 'MongoMS:MongoBinaryDownload' ) ;
19
20
@@ -237,17 +238,26 @@ export default class MongoBinaryDownload {
237
238
} )
238
239
) ;
239
240
}
240
-
241
241
stream . on ( 'end' , ( ) => next ( ) ) ;
242
242
stream . resume ( ) ;
243
243
} ) ;
244
244
245
245
return new Promise ( ( resolve , reject ) => {
246
- extract . on ( 'finish' , ( ) => resolve ( ) ) ;
247
- extract . on ( 'error' , ( e ) => reject ( e ) ) ;
248
246
fs . createReadStream ( mongoDBArchive )
247
+ . on ( 'error' , ( err ) => {
248
+ reject ( 'Unable to open tarball ' + mongoDBArchive + ': ' + err ) ;
249
+ } )
249
250
. pipe ( createUnzip ( ) )
250
- . pipe ( extract ) ;
251
+ . on ( 'error' , ( err ) => {
252
+ reject ( 'Error during unzip for ' + mongoDBArchive + ': ' + err ) ;
253
+ } )
254
+ . pipe ( extract )
255
+ . on ( 'error' , ( err ) => {
256
+ reject ( 'Error during untar for ' + mongoDBArchive + ': ' + err ) ;
257
+ } )
258
+ . on ( 'finish' , ( result ) => {
259
+ resolve ( result ) ;
260
+ } ) ;
251
261
} ) ;
252
262
}
253
263
@@ -304,10 +314,10 @@ export default class MongoBinaryDownload {
304
314
if ( response . statusCode != 200 ) {
305
315
if ( response . statusCode === 403 ) {
306
316
reject (
307
- new Error (
308
- " Status Code is 403 (MongoDB's 404)\n" +
309
- ' This means that the requested version-platform combination dosnt exist'
310
- )
317
+ new Error ( dedent `
318
+ Status Code is 403 (MongoDB's 404)\n
319
+ This means that the requested version-platform combination dosnt exist
320
+ ` )
311
321
) ;
312
322
return ;
313
323
}
@@ -375,8 +385,7 @@ export default class MongoBinaryDownload {
375
385
376
386
const crReturn = this . platform === 'win32' ? '\x1b[0G' : '\r' ;
377
387
process . stdout . write (
378
- `Downloading MongoDB ${ this . version } : ${ percentComplete } % (${ mbComplete } mb ` +
379
- `/ ${ this . dlProgress . totalMb } mb)${ crReturn } `
388
+ `Downloading MongoDB ${ this . version } : ${ percentComplete } % (${ mbComplete } mb / ${ this . dlProgress . totalMb } mb)${ crReturn } `
380
389
) ;
381
390
}
382
391
0 commit comments