This commit is contained in:
YouROK
2020-11-25 16:59:54 +03:00
parent cb74792d4d
commit 550e279110
2 changed files with 13 additions and 8 deletions

View File

@@ -58,6 +58,9 @@ func ListViewed(hash string) []*Viewed {
var err error
if hash != "" {
buf := tdb.Get("Viewed", hash)
if len(buf) == 0 {
return []*Viewed{}
}
var indeces map[int]struct{}
err = json.Unmarshal(buf, &indeces)
if err == nil {
@@ -72,6 +75,9 @@ func ListViewed(hash string) []*Viewed {
keys := tdb.List("Viewed")
for _, key := range keys {
buf := tdb.Get("Viewed", key)
if len(buf) == 0 {
return []*Viewed{}
}
var indeces map[int]struct{}
err = json.Unmarshal(buf, &indeces)
if err == nil {
@@ -86,5 +92,5 @@ func ListViewed(hash string) []*Viewed {
if err != nil {
log.TLogln("Error list viewed:", err)
}
return nil
return []*Viewed{}
}

View File

@@ -62,13 +62,12 @@ func GetTorrent(hashHex string) *Torrent {
tor = GetTorrentDB(hash)
tr, err := NewTorrent(tor.TorrentSpec, bts)
if err != nil {
log.TLogln("error get torrent db:", err)
}
go func() {
tr, _ := NewTorrent(tor.TorrentSpec, bts)
if tr != nil {
go tr.GotInfo()
tr.GotInfo()
}
}()
return tor
}