mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
change to use readers
This commit is contained in:
@@ -314,6 +314,21 @@ func (c *Cache) NewReader(file *torrent.File) *Reader {
|
|||||||
return newReader(file, c)
|
return newReader(file, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Cache) GetUseReaders() int {
|
||||||
|
if c == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
c.muReaders.Lock()
|
||||||
|
defer c.muReaders.Unlock()
|
||||||
|
readers := 0
|
||||||
|
for reader := range c.readers {
|
||||||
|
if reader.isUse {
|
||||||
|
readers++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return readers
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Cache) Readers() int {
|
func (c *Cache) Readers() int {
|
||||||
if c == nil {
|
if c == nil {
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ func (t *Torrent) drop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Torrent) Close() bool {
|
func (t *Torrent) Close() bool {
|
||||||
if t.cache != nil && t.cache.Readers() > 0 {
|
if t.cache != nil && t.cache.GetUseReaders() > 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
t.Stat = state.TorrentClosed
|
t.Stat = state.TorrentClosed
|
||||||
|
|||||||
Reference in New Issue
Block a user