This commit is contained in:
YouROK
2020-11-25 15:42:31 +03:00
parent e36f01bf5e
commit cb74792d4d
2 changed files with 24 additions and 15 deletions

View File

@@ -56,10 +56,19 @@ func SaveTorrentToDB(torr *Torrent) {
func GetTorrent(hashHex string) *Torrent {
hash := metainfo.NewHashFromHex(hashHex)
tor := bts.GetTorrent(hash)
if tor == nil {
tor = GetTorrentDB(hash)
if tor != nil {
return tor
}
tor = GetTorrentDB(hash)
tr, err := NewTorrent(tor.TorrentSpec, bts)
if err != nil {
log.TLogln("error get torrent db:", err)
}
if tr != nil {
go tr.GotInfo()
}
return tor
}