File tree Expand file tree Collapse file tree 1 file changed +19
-31
lines changed Expand file tree Collapse file tree 1 file changed +19
-31
lines changed Original file line number Diff line number Diff line change @@ -651,42 +651,30 @@ export class TransferManager {
651
651
let chunkEnd = start + chunkSize - 1 ;
652
652
chunkEnd = chunkEnd > size ? size : chunkEnd ;
653
653
promises . push (
654
- limit ( ( ) =>
655
- file
656
- . download ( {
657
- start : chunkStart ,
658
- end : chunkEnd ,
659
- [ GCCL_GCS_CMD_KEY ] : GCCL_GCS_CMD_FEATURE . DOWNLOAD_SHARDED ,
660
- } )
661
- . then ( resp => {
662
- return fileToWrite . write ( resp [ 0 ] , 0 , resp [ 0 ] . length , chunkStart ) ;
663
- } )
664
- )
654
+ limit ( async ( ) => {
655
+ const resp = await file . download ( {
656
+ start : chunkStart ,
657
+ end : chunkEnd ,
658
+ [ GCCL_GCS_CMD_KEY ] : GCCL_GCS_CMD_FEATURE . DOWNLOAD_SHARDED ,
659
+ } ) ;
660
+ return fileToWrite . write ( resp [ 0 ] , 0 , resp [ 0 ] . length , chunkStart ) ;
661
+ } )
665
662
) ;
666
663
667
664
start += chunkSize ;
668
665
}
669
666
670
- return new Promise ( ( resolve , reject ) => {
671
- let results : DownloadResponse ;
672
- Promise . all ( promises )
673
- . then ( data => {
674
- results = data . map ( result => result . buffer ) as DownloadResponse ;
675
- if ( options . validation === 'crc32c' ) {
676
- return CRC32C . fromFile ( filePath ) ;
677
- }
678
- return ;
679
- } )
680
- . then ( ( ) => {
681
- resolve ( results ) ;
682
- } )
683
- . catch ( e => {
684
- reject ( e ) ;
685
- } )
686
- . finally ( ( ) => {
687
- fileToWrite . close ( ) ;
688
- } ) ;
689
- } ) ;
667
+ let results : DownloadResponse ;
668
+ try {
669
+ const data = await Promise . all ( promises ) ;
670
+ results = data . map ( result => result . buffer ) as DownloadResponse ;
671
+ if ( options . validation === 'crc32c' ) {
672
+ await CRC32C . fromFile ( filePath ) ;
673
+ }
674
+ return results ;
675
+ } finally {
676
+ fileToWrite . close ( ) ;
677
+ }
690
678
}
691
679
692
680
/**
You can’t perform that action at this time.
0 commit comments