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:
authorSidd Sridharan <sidd@sidd.com>2016-12-06 09:07:58 +0300
committerSidd Sridharan <sidd@sidd.com>2016-12-06 09:09:32 +0300
commite1e543b33d232c7a4f935f26da94094aee6c9670 (patch)
tree4427ca4d3a8e8f039c452d85d12976f7e4bc63f2 /lib
parent8b365441fa47fe1a3622c1053df8def4370d6db5 (diff)
don't emit 'completed' on client.seed
Diffstat (limited to 'lib')
-rw-r--r--lib/torrent.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/torrent.js b/lib/torrent.js
index 0b69556..d9ade9a 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -1532,7 +1532,7 @@ Torrent.prototype._request = function (wire, index, hotswap) {
wire.have(index)
})
- self._checkDone()
+ self._checkDone(onDone)
} else {
self.pieces[index] = new Piece(piece.length)
self.emit('warning', new Error('Piece ' + index + ' failed verification'))
@@ -1541,6 +1541,10 @@ Torrent.prototype._request = function (wire, index, hotswap) {
})
})
+ function onDone () {
+ self.discovery.complete()
+ }
+
function onUpdateTick () {
process.nextTick(function () { self._update() })
}
@@ -1548,9 +1552,10 @@ Torrent.prototype._request = function (wire, index, hotswap) {
return true
}
-Torrent.prototype._checkDone = function () {
+Torrent.prototype._checkDone = function (cb) {
var self = this
if (self.destroyed) return
+ if (!cb) cb = noop
// are any new files done?
self.files.forEach(function (file) {
@@ -1579,7 +1584,7 @@ Torrent.prototype._checkDone = function () {
if (!self.done && done) {
self.done = true
self._debug('torrent done: ' + self.infoHash)
- self.discovery.complete()
+ cb(null)
self.emit('done')
}