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

@@ -11,8 +11,11 @@ type BTSets struct {
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
// Disk
UseDisk bool UseDisk bool
TorrentsSavePath string TorrentsSavePath string
RemoveCacheOnDrop bool
// Torrent // Torrent
ForceEncrypt bool ForceEncrypt bool

View File

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