This commit is contained in:
YouROK
2021-05-17 14:55:57 +03:00
parent 29f13fd482
commit e578628886
40 changed files with 1319 additions and 656 deletions

View File

@@ -3,6 +3,7 @@ package torr
import (
"io"
"os"
"path/filepath"
"sort"
"time"
@@ -52,6 +53,9 @@ func AddTorrent(spec *torrent.TorrentSpec, title, poster string, data string) (*
if title == "" && torDB != nil {
torr.Title = torDB.Title
}
if torr.Title == "" && torr.Torrent != nil && torr.Torrent.Info() != nil {
torr.Title = torr.Info().Name
}
}
if torr.Poster == "" {
torr.Poster = poster
@@ -123,6 +127,20 @@ func RemTorrent(hashHex string) {
hash := metainfo.NewHashFromHex(hashHex)
bts.RemoveTorrent(hash)
RemTorrentDB(hash)
if sets.BTsets.UseDisk &&
hashHex != "" &&
hashHex != "/" &&
sets.BTsets.TorrentsSavePath != "" &&
sets.BTsets.TorrentsSavePath != "/" {
name := filepath.Join(sets.BTsets.TorrentsSavePath, hashHex)
err := os.RemoveAll(name)
if err != nil {
log.TLogln("Error remove cache:", err)
} else {
log.TLogln("Remove cache from disk:", hashHex)
}
}
}
func ListTorrent() []*Torrent {