@@ -1231,23 +1231,25 @@ class ReceiveFileDialog extends ReceiveDialog {
12311231 }
12321232
12331233 async _processDataAsZip ( ) {
1234- let zipFileUrl , zipFileName ;
1234+ let zipObjectUrl = "" ;
1235+ let zipName = "" ;
12351236 let sendAsZip = false ;
12361237
12371238 const tooBigToZip = window . iOS && this . _data . totalSize > 256000000 ;
1239+
12381240 if ( this . _data . files . length > 1 && ! tooBigToZip ) {
1239- zipFileUrl = await this . _createZipFile ( this . _data . files , zipProgress => {
1240- Events . fire ( 'set-progress' , {
1241- peerId : this . _data . peerId ,
1242- progress : zipProgress / this . _data . totalSize ,
1243- status : 'process'
1244- } )
1245- } ) ;
1246- zipFileName = this . _createZipFilename ( )
1241+ zipObjectUrl = await zipper . getObjectUrlOfZipFile ( this . _data . files , zipProgress => {
1242+ Events . fire ( 'set-progress' , {
1243+ peerId : this . _data . peerId ,
1244+ progress : zipProgress / this . _data . totalSize ,
1245+ status : 'process'
1246+ } ) ;
1247+ } ) ;
1248+ zipName = this . _createZipFilename ( ) ;
12471249
1248- sendAsZip = ! ! zipFileUrl ;
1250+ sendAsZip = ! ! zipObjectUrl ;
12491251 }
1250- return { sendAsZip, zipFileUrl , zipFileName } ;
1252+ return { sendAsZip, zipObjectUrl , zipName } ;
12511253 }
12521254
12531255 _setDownloadButtonToZip ( zipFileUrl , zipFileName ) {
@@ -1318,27 +1320,6 @@ class ReceiveFileDialog extends ReceiveDialog {
13181320 }
13191321 }
13201322
1321- async _createZipFile ( files , onProgressCallback ) {
1322- try {
1323- let bytesCompleted = 0 ;
1324-
1325- zipper . createNewZipWriter ( ) ;
1326-
1327- for ( let i = 0 ; i < files . length ; i ++ ) {
1328- await zipper . addFile ( files [ i ] , {
1329- onprogress : ( progress ) => onProgressCallback ( bytesCompleted + progress )
1330- } ) ;
1331- bytesCompleted += files [ i ] . size ;
1332- }
1333-
1334- return await zipper . getBlobURL ( ) ;
1335- }
1336- catch ( e ) {
1337- Logger . error ( e ) ;
1338- return false ;
1339- }
1340- }
1341-
13421323 _createZipFilename ( ) {
13431324 let now = new Date ( Date . now ( ) ) ;
13441325 let year = now . getFullYear ( ) . toString ( ) ;
@@ -1373,11 +1354,11 @@ class ReceiveFileDialog extends ReceiveDialog {
13731354 this . $downloadBtn . removeAttribute ( 'disabled' ) ;
13741355 this . $downloadBtn . removeAttribute ( 'hidden' ) ;
13751356
1376- let { sendAsZip, zipFileUrl , zipFileName } = await this . _processDataAsZip ( ) ;
1357+ let { sendAsZip, zipObjectUrl , zipName } = await this . _processDataAsZip ( ) ;
13771358
13781359 // If single file or zipping failed -> download files individually -> else download zip
13791360 if ( sendAsZip ) {
1380- this . _setDownloadButtonToZip ( zipFileUrl , zipFileName ) ;
1361+ this . _setDownloadButtonToZip ( zipObjectUrl , zipName ) ;
13811362 } else {
13821363 this . _setDownloadButtonToFiles ( this . _data . files ) ;
13831364 }
0 commit comments