Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe ALLEGRO <jipai13@gmail.com>2020-10-06 21:46:03 +0300
committerGitHub <noreply@github.com>2020-10-06 21:46:03 +0300
commit4a5597149541709a1a95bcd46bfbb7efcf3b4102 (patch)
treeff22117678171f42b4425a3df97356b8d36439c7 /lib/torrent.js
parentf83f370e541807cedacfc0e93dbff08cadb4a18a (diff)
keeping code consistency
applying changes according to @alxhotel suggestion https://github.com/webtorrent/webtorrent/pull/1925#discussion_r499647106
Diffstat (limited to 'lib/torrent.js')
-rw-r--r--lib/torrent.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/torrent.js b/lib/torrent.js
index 0fb0145..e2ee673 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -921,7 +921,8 @@ class Torrent extends EventEmitter {
this._downloadSpeed(downloaded)
this.client._downloadSpeed(downloaded)
this.emit('download', downloaded)
- if (this.client) this.client.emit('download', downloaded)
+ if (this.destroyed) return
+ this.client.emit('download', downloaded)
})
wire.on('upload', uploaded => {
@@ -930,7 +931,8 @@ class Torrent extends EventEmitter {
this._uploadSpeed(uploaded)
this.client._uploadSpeed(uploaded)
this.emit('upload', uploaded)
- if (this.client) this.client.emit('upload', uploaded)
+ if (this.destroyed) return
+ this.client.emit('upload', uploaded)
})
this.wires.push(wire)