Merge pull request #70 from chihaya/lastbadreq
tracker: remove last "bad request"
This commit is contained in:
commit
5afdc7738e
1 changed files with 7 additions and 8 deletions
|
@ -226,12 +226,7 @@ func (tkr *Tracker) handlePeerEvent(ann *models.Announce, p *models.Peer) (snatc
|
||||||
}
|
}
|
||||||
|
|
||||||
case ann.Event == "completed":
|
case ann.Event == "completed":
|
||||||
if t.Leechers.Contains(p.Key()) {
|
tkr.leecherFinished(t, p)
|
||||||
err = tkr.leecherFinished(t, p)
|
|
||||||
} else {
|
|
||||||
err = models.ErrBadRequest
|
|
||||||
}
|
|
||||||
|
|
||||||
snatched = true
|
snatched = true
|
||||||
|
|
||||||
case t.Leechers.Contains(p.Key()) && ann.Left == 0:
|
case t.Leechers.Contains(p.Key()) && ann.Left == 0:
|
||||||
|
@ -244,12 +239,16 @@ func (tkr *Tracker) handlePeerEvent(ann *models.Announce, p *models.Peer) (snatc
|
||||||
|
|
||||||
// leecherFinished moves a peer from the leeching pool to the seeder pool.
|
// leecherFinished moves a peer from the leeching pool to the seeder pool.
|
||||||
func (tkr *Tracker) leecherFinished(t *models.Torrent, p *models.Peer) error {
|
func (tkr *Tracker) leecherFinished(t *models.Torrent, p *models.Peer) error {
|
||||||
if err := tkr.DeleteLeecher(t.Infohash, p); err != nil {
|
if t.Leechers.Contains(p.Key()) {
|
||||||
return err
|
if err := tkr.DeleteLeecher(t.Infohash, p); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := tkr.PutSeeder(t.Infohash, p); err != nil {
|
if err := tkr.PutSeeder(t.Infohash, p); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
stats.RecordPeerEvent(stats.Completed, p.HasIPv6())
|
stats.RecordPeerEvent(stats.Completed, p.HasIPv6())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue