update auth

This commit is contained in:
YouROK
2021-03-11 15:17:58 +03:00
parent 001faf7a97
commit 5eaa673149

View File

@@ -138,6 +138,7 @@ func streamNoAuth(c *gin.Context) {
_, preload := c.GetQuery("preload")
title := c.Query("title")
poster := c.Query("poster")
data := ""
if link == "" {
c.AbortWithError(http.StatusBadRequest, errors.New("link should not be empty"))
@@ -162,10 +163,24 @@ func streamNoAuth(c *gin.Context) {
}
tor := torr.GetTorrent(spec.InfoHash.HexString())
if tor == nil {
c.AbortWithError(http.StatusNotFound, errors.New("Torrent not found"))
if tor != nil {
title = tor.Title
poster = tor.Poster
data = tor.Data
}
if tor == nil || tor.Stat == state.TorrentInDB {
if title == "" {
title = c.Param("fname")
title, _ = url.PathUnescape(title)
title = strings.TrimLeft(title, "/")
}
tor, err = torr.AddTorrent(spec, title, poster, data)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
}
if !tor.GotInfo() {
c.AbortWithError(http.StatusInternalServerError, errors.New("timeout connection torrent"))