Don't consider errored snatches to be snatches
This commit is contained in:
parent
6f514cbad5
commit
2a12685007
1 changed files with 11 additions and 9 deletions
|
@ -34,10 +34,9 @@ func (tkr *Tracker) HandleAnnounce(ann *models.Announce, w Writer) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var torrent *models.Torrent
|
torrent, err := conn.FindTorrent(ann.Infohash)
|
||||||
torrent, err = conn.FindTorrent(ann.Infohash)
|
|
||||||
switch {
|
if err == models.ErrTorrentDNE && !tkr.cfg.PrivateEnabled {
|
||||||
case !tkr.cfg.PrivateEnabled && err == models.ErrTorrentDNE:
|
|
||||||
torrent = &models.Torrent{
|
torrent = &models.Torrent{
|
||||||
Infohash: ann.Infohash,
|
Infohash: ann.Infohash,
|
||||||
Seeders: models.PeerMap{},
|
Seeders: models.PeerMap{},
|
||||||
|
@ -49,8 +48,7 @@ func (tkr *Tracker) HandleAnnounce(ann *models.Announce, w Writer) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
stats.RecordEvent(stats.NewTorrent)
|
stats.RecordEvent(stats.NewTorrent)
|
||||||
|
} else if err != nil {
|
||||||
case err != nil:
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +93,12 @@ func updateSwarm(c Conn, ann *models.Announce) (created bool, err error) {
|
||||||
}
|
}
|
||||||
if ann.HasIPv6() {
|
if ann.HasIPv6() {
|
||||||
createdv6, err = updatePeer(c, ann, ann.PeerV6)
|
createdv6, err = updatePeer(c, ann, ann.PeerV6)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return createdv4 || createdv6, err
|
}
|
||||||
|
|
||||||
|
return createdv4 || createdv6, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func updatePeer(c Conn, ann *models.Announce, peer *models.Peer) (created bool, err error) {
|
func updatePeer(c Conn, ann *models.Announce, peer *models.Peer) (created bool, err error) {
|
||||||
|
@ -207,8 +209,8 @@ func handlePeerEvent(c Conn, ann *models.Announce, p *models.Peer) (snatched boo
|
||||||
err = models.ErrBadRequest
|
err = models.ErrBadRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
// If one of the dual-stacked peers is already a seeder, they have already
|
// If one of the dual-stacked peers is already a seeder, they have
|
||||||
// snatched.
|
// already snatched.
|
||||||
if !(v4seed || v6seed) {
|
if !(v4seed || v6seed) {
|
||||||
snatched = true
|
snatched = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue