From 068de3c56557045472860e74a18d74ba238a53b9 Mon Sep 17 00:00:00 2001 From: yourok <8yourok8@mail.ru> Date: Mon, 8 Jan 2024 18:24:48 +0300 Subject: [PATCH] disable close torrent on reading it --- server/torr/apihelper.go | 3 --- server/torr/torrent.go | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/torr/apihelper.go b/server/torr/apihelper.go index 247adc7..1384ec0 100644 --- a/server/torr/apihelper.go +++ b/server/torr/apihelper.go @@ -139,9 +139,6 @@ func SetTorrent(hashHex, title, poster, data string) *Torrent { } func RemTorrent(hashHex string) { - if sets.ReadOnly { - return - } hash := metainfo.NewHashFromHex(hashHex) if sets.BTsets.UseDisk && hashHex != "" && hashHex != "/" { name := filepath.Join(sets.BTsets.TorrentsSavePath, hashHex) diff --git a/server/torr/torrent.go b/server/torr/torrent.go index 694602e..a67a87d 100644 --- a/server/torr/torrent.go +++ b/server/torr/torrent.go @@ -266,6 +266,9 @@ func (t *Torrent) drop() { } func (t *Torrent) Close() { + if t.cache != nil && t.cache.Readers() > 0 { + return + } t.Stat = state.TorrentClosed t.bt.mu.Lock()