This commit is contained in:
Daniel Shleifman
2021-06-03 13:03:25 +03:00
2 changed files with 21 additions and 10 deletions

View File

@@ -8,11 +8,14 @@ import (
type BTSets struct {
// Cache
CacheSize int64 // in byte, def 200 mb
PreloadBuffer bool
ReaderReadAHead int // in percent, 5%-100%, [...S__X__E...] [S-E] not clean
UseDisk bool
TorrentsSavePath string
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

View File

@@ -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()