Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't send 'completed' event to tracker on client.seed #991

Merged
merged 2 commits into from Jan 18, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

don't emit 'completed' on client.seed

  • Loading branch information
sidd committed Dec 6, 2016
commit e1e543b33d232c7a4f935f26da94094aee6c9670
@@ -1532,7 +1532,7 @@ Torrent.prototype._request = function (wire, index, hotswap) {
wire.have(index)
})

self._checkDone()
self._checkDone(onDone)

This comment has been minimized.

Copy link
@feross

feross Dec 8, 2016

Member

If this returns true, then we can call self.discovery.complete().

} else {
self.pieces[index] = new Piece(piece.length)
self.emit('warning', new Error('Piece ' + index + ' failed verification'))
@@ -1541,16 +1541,21 @@ Torrent.prototype._request = function (wire, index, hotswap) {
})
})

function onDone () {
self.discovery.complete()
}

function onUpdateTick () {
process.nextTick(function () { self._update() })
}

return true
}

Torrent.prototype._checkDone = function () {
Torrent.prototype._checkDone = function (cb) {

This comment has been minimized.

Copy link
@feross

feross Dec 8, 2016

Member

No need for a callback. This method is entirely sync. Let's just return true if the entire torrent is done, false otherwise.

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')

This comment has been minimized.

Copy link
@feross

feross Dec 8, 2016

Member

Let's return true at the very end of this if statement.

This comment has been minimized.

Copy link
@sidd

sidd Dec 8, 2016

Author Contributor

Returning true before _gcSelections seems to be causing tests to hang. getBuffer never calls its callback: https://github.com/feross/webtorrent/blob/master/test/node/download-dht-magnet.js#L77. return done after _gcSelections the function resolves this. Thoughts?

This comment has been minimized.

Copy link
@feross

feross Jan 18, 2017

Member

Yeah, good point

}

This comment has been minimized.

Copy link
@feross

feross Dec 8, 2016

Member

Otherwise, return false.


ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.