prefer dn over name with empty title

This commit is contained in:
nikk gitanes
2021-08-09 08:24:21 +03:00
parent 8dad8862f5
commit 867709e5a3

View File

@@ -71,7 +71,7 @@ func addTorrent(req torrReqJS, c *gin.Context) {
req.Link = strings.ReplaceAll(req.Link, "&", "&")
torrSpec, err := utils.ParseLink(req.Link)
if err != nil {
log.TLogln("error add torrent:", err)
log.TLogln("error parse link:", err)
c.AbortWithError(http.StatusBadRequest, err)
return
}
@@ -85,13 +85,16 @@ func addTorrent(req torrReqJS, c *gin.Context) {
go func() {
if !tor.GotInfo() {
log.TLogln("error add torrent:", "timeout connection torrent")
log.TLogln("error add torrent:", "timeout connection get torrent info")
return
}
if tor.Title == "" {
tor.Title = torrSpec.DisplayName // prefer dn over name
if tor.Title == "" {
tor.Title = tor.Name()
}
}
if req.SaveToDB {
torr.SaveTorrentToDB(tor)