mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
add remove disk cache on drop
This commit is contained in:
@@ -8,11 +8,14 @@ import (
|
|||||||
|
|
||||||
type BTSets struct {
|
type BTSets struct {
|
||||||
// Cache
|
// Cache
|
||||||
CacheSize int64 // in byte, def 200 mb
|
CacheSize int64 // in byte, def 200 mb
|
||||||
PreloadBuffer bool
|
PreloadBuffer bool
|
||||||
ReaderReadAHead int // in percent, 5%-100%, [...S__X__E...] [S-E] not clean
|
ReaderReadAHead int // in percent, 5%-100%, [...S__X__E...] [S-E] not clean
|
||||||
UseDisk bool
|
|
||||||
TorrentsSavePath string
|
// Disk
|
||||||
|
UseDisk bool
|
||||||
|
TorrentsSavePath string
|
||||||
|
RemoveCacheOnDrop bool
|
||||||
|
|
||||||
// Torrent
|
// Torrent
|
||||||
ForceEncrypt bool
|
ForceEncrypt bool
|
||||||
|
|||||||
@@ -90,11 +90,19 @@ func (c *Cache) Piece(m metainfo.Piece) storage.PieceImpl {
|
|||||||
func (c *Cache) Close() error {
|
func (c *Cache) Close() error {
|
||||||
log.TLogln("Close cache for:", c.hash)
|
log.TLogln("Close cache for:", c.hash)
|
||||||
delete(c.storage.caches, c.hash)
|
delete(c.storage.caches, c.hash)
|
||||||
//for _, v := range c.pieces {
|
|
||||||
// if v.dPiece != nil {
|
if settings.BTsets.RemoveCacheOnDrop {
|
||||||
// os.Remove(v.dPiece.name)
|
name := filepath.Join(settings.BTsets.TorrentsSavePath, c.hash.HexString())
|
||||||
// }
|
if name != "" && name != "/" {
|
||||||
//}
|
for _, v := range c.pieces {
|
||||||
|
if v.dPiece != nil {
|
||||||
|
os.Remove(v.dPiece.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os.Remove(name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c.pieces = nil
|
c.pieces = nil
|
||||||
|
|
||||||
c.muReaders.Lock()
|
c.muReaders.Lock()
|
||||||
|
|||||||
Reference in New Issue
Block a user