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
path: root/lib
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2019-09-07 03:30:59 +0300
committerFeross Aboukhadijeh <feross@feross.org>2019-09-07 03:30:59 +0300
commitef6879a8daca46edc5e2de2febc09d4c87e47988 (patch)
treecc9635268a70352d090c00d98ebe57923c49816a /lib
parent7db0b2c9e90a240f500a9810b6a80378f94b8c2a (diff)
User might destroy torrent in response to 'metadata' event
Fixes: https://github.com/webtorrent/webtorrent-cli/issues/112 Fix for PR https://github.com/webtorrent/webtorrent/pull/1737
Diffstat (limited to 'lib')
-rw-r--r--lib/torrent.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/torrent.js b/lib/torrent.js
index f2c1432..f56b75c 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -508,6 +508,9 @@ class Torrent extends EventEmitter {
// Emit 'metadata' before 'ready' and 'done'
this.emit('metadata')
+ // User might destroy torrent in response to 'metadata' event
+ if (this.destroyed) return
+
if (this.skipVerify) {
// Skip verifying exisitng data and just assume it's correct
this._markAllVerified()