mirror of
https://github.com/LBRYFoundation/tracker.git
synced 2025-08-23 17:47:29 +00:00
when public, create non-existing torrents
This commit is contained in:
parent
3cc4679454
commit
0f734a6069
1 changed files with 18 additions and 3 deletions
|
@ -51,11 +51,26 @@ func (t *Tracker) ServeAnnounce(w http.ResponseWriter, r *http.Request, p httpro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent, err := conn.FindTorrent(ann.Infohash)
|
var torrent *models.Torrent
|
||||||
if err == tracker.ErrTorrentDNE {
|
torrent, err = conn.FindTorrent(ann.Infohash)
|
||||||
|
switch {
|
||||||
|
case t.cfg.Private && err == tracker.ErrTorrentDNE:
|
||||||
|
torrent = &models.Torrent{
|
||||||
|
Infohash: ann.Infohash,
|
||||||
|
Seeders: make(map[string]models.Peer),
|
||||||
|
Leechers: make(map[string]models.Peer),
|
||||||
|
}
|
||||||
|
|
||||||
|
err = conn.PutTorrent(torrent)
|
||||||
|
if err != nil {
|
||||||
|
return http.StatusInternalServerError, err
|
||||||
|
}
|
||||||
|
|
||||||
|
case !t.cfg.Private && err == tracker.ErrTorrentDNE:
|
||||||
fail(w, r, err)
|
fail(w, r, err)
|
||||||
return http.StatusOK, nil
|
return http.StatusOK, nil
|
||||||
} else if err != nil {
|
|
||||||
|
case err != nil:
|
||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue