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:
@@ -11,8 +11,11 @@ type BTSets struct {
|
||||
CacheSize int64 // in byte, def 200 mb
|
||||
PreloadBuffer bool
|
||||
ReaderReadAHead int // in percent, 5%-100%, [...S__X__E...] [S-E] not clean
|
||||
|
||||
// Disk
|
||||
UseDisk bool
|
||||
TorrentsSavePath string
|
||||
RemoveCacheOnDrop bool
|
||||
|
||||
// Torrent
|
||||
ForceEncrypt bool
|
||||
|
||||
@@ -90,11 +90,19 @@ func (c *Cache) Piece(m metainfo.Piece) storage.PieceImpl {
|
||||
func (c *Cache) Close() error {
|
||||
log.TLogln("Close cache for:", c.hash)
|
||||
delete(c.storage.caches, c.hash)
|
||||
//for _, v := range c.pieces {
|
||||
// if v.dPiece != nil {
|
||||
// os.Remove(v.dPiece.name)
|
||||
// }
|
||||
//}
|
||||
|
||||
if settings.BTsets.RemoveCacheOnDrop {
|
||||
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.muReaders.Lock()
|
||||
|
||||
Reference in New Issue
Block a user