@@ -102,7 +102,7 @@ export class TorrentService {
102
102
*/
103
103
private setupWebTorrent ( wasCrash = false ) {
104
104
this . webTorrent = new WebTorrent ( {
105
- maxConns : 55 , // Is the default
105
+ maxConns : 55 // Is the default
106
106
} )
107
107
108
108
this . webTorrent . on ( 'error' , ( error ) => {
@@ -311,7 +311,7 @@ export class TorrentService {
311
311
// Add a unique download location for this item
312
312
path : this . getDownloadLocation ( download ) ,
313
313
maxWebConns : 5 ,
314
- announce : this . trackers ,
314
+ announce : this . trackers
315
315
} ,
316
316
this . handleTorrent ( resolve , item , download , magnet )
317
317
)
@@ -375,27 +375,47 @@ export class TorrentService {
375
375
// Keep track if we are currently updating the model, prevents updating same item twice at the same time
376
376
let updatingModel = false
377
377
378
+ torrent . on ( 'error' , async ( err ) => {
379
+ this . logger . error ( `[${ download . _id } ]: Torrent error` , err )
380
+
381
+ await this . updateOne ( item , {
382
+ download : {
383
+ downloadStatus : TorrentService . STATUS_FAILED ,
384
+ downloading : false
385
+ }
386
+ } )
387
+
388
+ // Remove from torrents
389
+ this . removeFromTorrents ( download )
390
+
391
+ // Also cleanup this download
392
+ await this . cleanUpDownload ( download )
393
+
394
+ this . removeFromWebTorrent ( magnet )
395
+
396
+ // Resolve instead of reject as no try catch is around the method
397
+ resolve ( )
398
+ } )
399
+
378
400
torrent . on ( 'noPeers' , async ( announceType ) => {
379
- if ( announceType === 'dht' ) {
380
- this . logger . warn ( `[${ download . _id } ]: No peers found` )
381
- await this . updateOne ( item , {
382
- download : {
383
- downloadStatus : TorrentService . STATUS_FAILED ,
384
- downloading : false
385
- }
386
- } )
401
+ this . logger . warn ( `[${ download . _id } ]: No peers found, announce type: ${ announceType } ` )
402
+ await this . updateOne ( item , {
403
+ download : {
404
+ downloadStatus : TorrentService . STATUS_FAILED ,
405
+ downloading : false
406
+ }
407
+ } )
387
408
388
- // Remove from torrents
389
- this . removeFromTorrents ( download )
409
+ // Remove from torrents
410
+ this . removeFromTorrents ( download )
390
411
391
- // Also cleanup this download
392
- await this . cleanUpDownload ( download )
412
+ // Also cleanup this download
413
+ await this . cleanUpDownload ( download )
393
414
394
- this . removeFromWebTorrent ( magnet )
415
+ this . removeFromWebTorrent ( magnet )
395
416
396
- // Resolve instead of reject as no try catch is around the method
397
- resolve ( )
398
- }
417
+ // Resolve instead of reject as no try catch is around the method
418
+ resolve ( )
399
419
} )
400
420
401
421
torrent . on ( 'download' , async ( ) => {
0 commit comments