set torrent name if empty title

This commit is contained in:
YouROK
2021-06-17 10:57:28 +03:00
parent 108975774a
commit c31c318321

View File

@@ -107,21 +107,37 @@ func GetTorrent(hashHex string) *Torrent {
func SetTorrent(hashHex, title, poster, data string) *Torrent { func SetTorrent(hashHex, title, poster, data string) *Torrent {
hash := metainfo.NewHashFromHex(hashHex) hash := metainfo.NewHashFromHex(hashHex)
tor := bts.GetTorrent(hash) torr := bts.GetTorrent(hash)
if tor != nil { torrDb := GetTorrentDB(hash)
tor.Title = title
tor.Poster = poster if title == "" && torr == nil && torrDb != nil {
tor.Data = data torr = GetTorrent(hashHex)
torr.GotInfo()
if torr.Torrent != nil && torr.Torrent.Info() != nil {
title = torr.Info().Name
}
} }
tor = GetTorrentDB(hash) if torr != nil {
if tor != nil { if title == "" && torr.Torrent != nil && torr.Torrent.Info() != nil {
tor.Title = title title = torr.Info().Name
tor.Poster = poster }
tor.Data = data torr.Title = title
AddTorrentDB(tor) torr.Poster = poster
torr.Data = data
}
if torrDb != nil {
torrDb.Title = title
torrDb.Poster = poster
torrDb.Data = data
AddTorrentDB(torrDb)
}
if torr != nil {
return torr
} else {
return torrDb
} }
return tor
} }
func RemTorrent(hashHex string) { func RemTorrent(hashHex string) {