From 5ebba786d50077365b55c193df2d570bf5498b6e Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 11 May 2016 18:30:39 +0200 Subject: On duplicate torrent add, don't emit 'infoHash' Private 'infoHash' event allows client.add to check for duplicate torrents and destroy them before the normal 'infoHash' event is emitted. Prevents user applications from needing to deal with duplicate 'infoHash' events. --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'index.js') diff --git a/index.js b/index.js index f8194da..3a69d3c 100644 --- a/index.js +++ b/index.js @@ -240,7 +240,7 @@ WebTorrent.prototype.add = function (torrentId, opts, ontorrent) { var torrent = new Torrent(torrentId, self, opts) self.torrents.push(torrent) - torrent.once('infoHash', onInfoHash) + torrent.once('_infoHash', onInfoHash) torrent.once('ready', onReady) torrent.once('close', onClose) @@ -262,7 +262,7 @@ WebTorrent.prototype.add = function (torrentId, opts, ontorrent) { } function onClose () { - torrent.removeListener('infoHash', onInfoHash) + torrent.removeListener('_infoHash', onInfoHash) torrent.removeListener('ready', onReady) torrent.removeListener('close', onClose) } -- cgit v1.2.3