diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2017-01-18 11:15:49 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2017-01-18 11:15:49 +0300 |
commit | 6f3d4a54007909f9a22e4dc3bdefd40af0d39d6b (patch) | |
tree | 5bd17cb40a897763fd450e78c5f9b72be8f9d725 /lib | |
parent | e1e543b33d232c7a4f935f26da94094aee6c9670 (diff) |
Address feross's feedback
Diffstat (limited to 'lib')
-rw-r--r-- | lib/torrent.js | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index d9ade9a..ad0785d 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(onDone) + if (self._checkDone()) self.discovery.complete() } else { self.pieces[index] = new Piece(piece.length) self.emit('warning', new Error('Piece ' + index + ' failed verification')) @@ -1541,10 +1541,6 @@ Torrent.prototype._request = function (wire, index, hotswap) { }) }) - function onDone () { - self.discovery.complete() - } - function onUpdateTick () { process.nextTick(function () { self._update() }) } @@ -1552,10 +1548,9 @@ Torrent.prototype._request = function (wire, index, hotswap) { return true } -Torrent.prototype._checkDone = function (cb) { +Torrent.prototype._checkDone = function () { var self = this if (self.destroyed) return - if (!cb) cb = noop // are any new files done? self.files.forEach(function (file) { @@ -1584,11 +1579,11 @@ Torrent.prototype._checkDone = function (cb) { if (!self.done && done) { self.done = true self._debug('torrent done: ' + self.infoHash) - cb(null) self.emit('done') } - self._gcSelections() + + return done } Torrent.prototype.load = function (streams, cb) { |