@@ -60,13 +60,13 @@ export class DownloadTask {
60
60
const exists = fileIo . accessSync ( params . targetFile ) ;
61
61
if ( exists ) {
62
62
await fileIo . unlink ( params . targetFile ) ;
63
- } else {
63
+ } else {
64
64
const targetDir = params . targetFile . substring (
65
65
0 ,
66
66
params . targetFile . lastIndexOf ( '/' ) ,
67
67
) ;
68
68
const exists = fileIo . accessSync ( targetDir ) ;
69
- if ( ! exists ) {
69
+ if ( ! exists ) {
70
70
await fileIo . mkdir ( targetDir ) ;
71
71
}
72
72
}
@@ -83,7 +83,7 @@ export class DownloadTask {
83
83
} ,
84
84
} ) ;
85
85
if ( response . responseCode > 299 ) {
86
- throw new Error ( `Server error: ${ response . responseCode } ` ) ;
86
+ throw Error ( `Server error: ${ response . responseCode } ` ) ;
87
87
}
88
88
89
89
const contentLength = parseInt ( response . header [ 'content-length' ] || '0' ) ;
@@ -108,9 +108,10 @@ export class DownloadTask {
108
108
const stats = await fileIo . stat ( params . targetFile ) ;
109
109
const fileSize = stats . size ;
110
110
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
+ ) ;
112
114
}
113
-
114
115
} catch ( error ) {
115
116
console . error ( 'Download failed:' , error ) ;
116
117
throw error ;
@@ -142,7 +143,7 @@ export class DownloadTask {
142
143
bytesRead = await fileIo
143
144
. read ( reader . fd , arrayBuffer )
144
145
. catch ( ( err : BusinessError ) => {
145
- throw new Error (
146
+ throw Error (
146
147
`Error reading file: ${ err . message } , code: ${ err . code } ` ,
147
148
) ;
148
149
} ) ;
@@ -154,7 +155,7 @@ export class DownloadTask {
154
155
length : bytesRead ,
155
156
} )
156
157
. catch ( ( err : BusinessError ) => {
157
- throw new Error (
158
+ throw Error (
158
159
`Error writing file: ${ err . message } , code: ${ err . code } ` ,
159
160
) ;
160
161
} ) ;
@@ -295,16 +296,16 @@ export class DownloadTask {
295
296
}
296
297
}
297
298
298
- if ( fn !== '.DS_Store' ) {
299
+ if ( fn !== '.DS_Store' ) {
299
300
await zip . decompressFile ( fn , params . unzipDirectory ) ;
300
301
}
301
302
}
302
303
303
304
if ( ! foundDiff ) {
304
- throw new Error ( 'diff.json not found' ) ;
305
+ throw Error ( 'diff.json not found' ) ;
305
306
}
306
307
if ( ! foundBundlePatch ) {
307
- throw new Error ( 'bundle patch not found' ) ;
308
+ throw Error ( 'bundle patch not found' ) ;
308
309
}
309
310
await this . copyFromResource ( copyList ) ;
310
311
}
@@ -366,12 +367,18 @@ export class DownloadTask {
366
367
new Uint8Array ( entry . content ) ,
367
368
) ;
368
369
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
+ ) ;
370
374
const chunkSize = 4096 ;
371
375
let bytesWritten = 0 ;
372
376
const totalLength = patched . byteLength ;
373
377
while ( bytesWritten < totalLength ) {
374
- const chunk = patched . slice ( bytesWritten , bytesWritten + chunkSize ) ;
378
+ const chunk = patched . slice (
379
+ bytesWritten ,
380
+ bytesWritten + chunkSize ,
381
+ ) ;
375
382
await fileIo . write ( writer . fd , chunk ) ;
376
383
bytesWritten += chunk . byteLength ;
377
384
}
@@ -387,10 +394,10 @@ export class DownloadTask {
387
394
}
388
395
389
396
if ( ! foundDiff ) {
390
- throw new Error ( 'diff.json not found' ) ;
397
+ throw Error ( 'diff.json not found' ) ;
391
398
}
392
399
if ( ! foundBundlePatch ) {
393
- throw new Error ( 'bundle patch not found' ) ;
400
+ throw Error ( 'bundle patch not found' ) ;
394
401
}
395
402
console . info ( 'Patch from PPK completed' ) ;
396
403
}
@@ -478,7 +485,7 @@ export class DownloadTask {
478
485
await this . downloadFile ( params ) ;
479
486
break ;
480
487
default :
481
- throw new Error ( `Unknown task type: ${ params . type } ` ) ;
488
+ throw Error ( `Unknown task type: ${ params . type } ` ) ;
482
489
}
483
490
484
491
params . listener ?. onDownloadCompleted ( params ) ;
0 commit comments