mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
fix remove cache on disk on reading torrent
This commit is contained in:
@@ -140,18 +140,19 @@ func SetTorrent(hashHex, title, poster, data string) *Torrent {
|
|||||||
|
|
||||||
func RemTorrent(hashHex string) {
|
func RemTorrent(hashHex string) {
|
||||||
hash := metainfo.NewHashFromHex(hashHex)
|
hash := metainfo.NewHashFromHex(hashHex)
|
||||||
if sets.BTsets.UseDisk && hashHex != "" && hashHex != "/" {
|
if bts.RemoveTorrent(hash) {
|
||||||
name := filepath.Join(sets.BTsets.TorrentsSavePath, hashHex)
|
if sets.BTsets.UseDisk && hashHex != "" && hashHex != "/" {
|
||||||
ff, _ := os.ReadDir(name)
|
name := filepath.Join(sets.BTsets.TorrentsSavePath, hashHex)
|
||||||
for _, f := range ff {
|
ff, _ := os.ReadDir(name)
|
||||||
os.Remove(filepath.Join(name, f.Name()))
|
for _, f := range ff {
|
||||||
}
|
os.Remove(filepath.Join(name, f.Name()))
|
||||||
err := os.Remove(name)
|
}
|
||||||
if err != nil {
|
err := os.Remove(name)
|
||||||
log.TLogln("Error remove cache:", err)
|
if err != nil {
|
||||||
|
log.TLogln("Error remove cache:", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bts.RemoveTorrent(hash)
|
|
||||||
RemTorrentDB(hash)
|
RemTorrentDB(hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -200,10 +200,11 @@ func (bt *BTServer) ListTorrents() map[metainfo.Hash]*Torrent {
|
|||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bt *BTServer) RemoveTorrent(hash torrent.InfoHash) {
|
func (bt *BTServer) RemoveTorrent(hash torrent.InfoHash) bool {
|
||||||
if torr, ok := bt.torrents[hash]; ok {
|
if torr, ok := bt.torrents[hash]; ok {
|
||||||
torr.Close()
|
return torr.Close()
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func isPrivateIP(ip net.IP) bool {
|
func isPrivateIP(ip net.IP) bool {
|
||||||
|
|||||||
@@ -265,9 +265,9 @@ func (t *Torrent) drop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Torrent) Close() {
|
func (t *Torrent) Close() bool {
|
||||||
if t.cache != nil && t.cache.Readers() > 0 {
|
if t.cache != nil && t.cache.Readers() > 0 {
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
t.Stat = state.TorrentClosed
|
t.Stat = state.TorrentClosed
|
||||||
|
|
||||||
@@ -276,6 +276,7 @@ func (t *Torrent) Close() {
|
|||||||
t.bt.mu.Unlock()
|
t.bt.mu.Unlock()
|
||||||
|
|
||||||
t.drop()
|
t.drop()
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Torrent) Status() *state.TorrentStatus {
|
func (t *Torrent) Status() *state.TorrentStatus {
|
||||||
|
|||||||
Reference in New Issue
Block a user