Skip to content

Commit c98c40a

Browse files
authored
Merge pull request webtorrent#272 from qqdaiyu55/master
Fix filter function
2 parents e2b8262 + 2ba6946 commit c98c40a

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

server.js

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -659,32 +659,27 @@ Server.prototype._onAnnounce = function (params, cb) {
659659

660660
self.getSwarm(params.info_hash, function (err, swarm) {
661661
if (err) return cb(err)
662-
if (swarm) {
663-
announce(swarm)
664-
} else {
665-
createSwarm()
666-
}
667-
})
668662

669-
function createSwarm () {
670663
if (self._filter) {
671664
self._filter(params.info_hash, params, function (err) {
672-
// Precense of err means that this info_hash is disallowed
673-
if (err) {
674-
cb(err)
675-
} else {
676-
self.createSwarm(params.info_hash, function (err, swarm) {
677-
if (err) return cb(err)
678-
announce(swarm)
679-
})
665+
// Precense of err means that this torrent or user is disallowd
666+
if (err) cb(err)
667+
else {
668+
if (swarm) announce(swarm)
669+
else createSwarm()
680670
}
681671
})
682672
} else {
683-
self.createSwarm(params.info_hash, function (err, swarm) {
684-
if (err) return cb(err)
685-
announce(swarm)
686-
})
673+
if (swarm) announce(swarm)
674+
else createSwarm()
687675
}
676+
})
677+
678+
function createSwarm () {
679+
self.createSwarm(params.info_hash, function (err, swarm) {
680+
if (err) return cb(err)
681+
announce(swarm)
682+
})
688683
}
689684

690685
function announce (swarm) {

0 commit comments

Comments
 (0)