@@ -60,13 +60,13 @@ export class DownloadTask {
6060 const exists = fileIo . accessSync ( params . targetFile ) ;
6161 if ( exists ) {
6262 await fileIo . unlink ( params . targetFile ) ;
63- } else {
63+ } else {
6464 const targetDir = params . targetFile . substring (
6565 0 ,
6666 params . targetFile . lastIndexOf ( '/' ) ,
6767 ) ;
6868 const exists = fileIo . accessSync ( targetDir ) ;
69- if ( ! exists ) {
69+ if ( ! exists ) {
7070 await fileIo . mkdir ( targetDir ) ;
7171 }
7272 }
@@ -83,7 +83,7 @@ export class DownloadTask {
8383 } ,
8484 } ) ;
8585 if ( response . responseCode > 299 ) {
86- throw new Error ( `Server error: ${ response . responseCode } ` ) ;
86+ throw Error ( `Server error: ${ response . responseCode } ` ) ;
8787 }
8888
8989 const contentLength = parseInt ( response . header [ 'content-length' ] || '0' ) ;
@@ -108,9 +108,10 @@ export class DownloadTask {
108108 const stats = await fileIo . stat ( params . targetFile ) ;
109109 const fileSize = stats . size ;
110110 if ( fileSize !== contentLength ) {
111- throw new Error ( `Download incomplete: expected ${ contentLength } bytes but got ${ stats . size } bytes` ) ;
111+ throw Error (
112+ `Download incomplete: expected ${ contentLength } bytes but got ${ stats . size } bytes` ,
113+ ) ;
112114 }
113-
114115 } catch ( error ) {
115116 console . error ( 'Download failed:' , error ) ;
116117 throw error ;
@@ -142,7 +143,7 @@ export class DownloadTask {
142143 bytesRead = await fileIo
143144 . read ( reader . fd , arrayBuffer )
144145 . catch ( ( err : BusinessError ) => {
145- throw new Error (
146+ throw Error (
146147 `Error reading file: ${ err . message } , code: ${ err . code } ` ,
147148 ) ;
148149 } ) ;
@@ -154,7 +155,7 @@ export class DownloadTask {
154155 length : bytesRead ,
155156 } )
156157 . catch ( ( err : BusinessError ) => {
157- throw new Error (
158+ throw Error (
158159 `Error writing file: ${ err . message } , code: ${ err . code } ` ,
159160 ) ;
160161 } ) ;
@@ -295,16 +296,16 @@ export class DownloadTask {
295296 }
296297 }
297298
298- if ( fn !== '.DS_Store' ) {
299+ if ( fn !== '.DS_Store' ) {
299300 await zip . decompressFile ( fn , params . unzipDirectory ) ;
300301 }
301302 }
302303
303304 if ( ! foundDiff ) {
304- throw new Error ( 'diff.json not found' ) ;
305+ throw Error ( 'diff.json not found' ) ;
305306 }
306307 if ( ! foundBundlePatch ) {
307- throw new Error ( 'bundle patch not found' ) ;
308+ throw Error ( 'bundle patch not found' ) ;
308309 }
309310 await this . copyFromResource ( copyList ) ;
310311 }
@@ -366,12 +367,18 @@ export class DownloadTask {
366367 new Uint8Array ( entry . content ) ,
367368 ) ;
368369 const outputFile = `${ params . unzipDirectory } /bundle.harmony.js` ;
369- const writer = await fileIo . open ( outputFile , fileIo . OpenMode . CREATE | fileIo . OpenMode . WRITE_ONLY ) ;
370+ const writer = await fileIo . open (
371+ outputFile ,
372+ fileIo . OpenMode . CREATE | fileIo . OpenMode . WRITE_ONLY ,
373+ ) ;
370374 const chunkSize = 4096 ;
371375 let bytesWritten = 0 ;
372376 const totalLength = patched . byteLength ;
373377 while ( bytesWritten < totalLength ) {
374- const chunk = patched . slice ( bytesWritten , bytesWritten + chunkSize ) ;
378+ const chunk = patched . slice (
379+ bytesWritten ,
380+ bytesWritten + chunkSize ,
381+ ) ;
375382 await fileIo . write ( writer . fd , chunk ) ;
376383 bytesWritten += chunk . byteLength ;
377384 }
@@ -387,10 +394,10 @@ export class DownloadTask {
387394 }
388395
389396 if ( ! foundDiff ) {
390- throw new Error ( 'diff.json not found' ) ;
397+ throw Error ( 'diff.json not found' ) ;
391398 }
392399 if ( ! foundBundlePatch ) {
393- throw new Error ( 'bundle patch not found' ) ;
400+ throw Error ( 'bundle patch not found' ) ;
394401 }
395402 console . info ( 'Patch from PPK completed' ) ;
396403 }
@@ -478,7 +485,7 @@ export class DownloadTask {
478485 await this . downloadFile ( params ) ;
479486 break ;
480487 default :
481- throw new Error ( `Unknown task type: ${ params . type } ` ) ;
488+ throw Error ( `Unknown task type: ${ params . type } ` ) ;
482489 }
483490
484491 params . listener ?. onDownloadCompleted ( params ) ;
0 commit comments