safe UpdateCompletion() on Release()

This commit is contained in:
nikk gitanes
2021-08-22 19:37:47 +03:00
parent f8014e9853
commit 001a3c292b
4 changed files with 8 additions and 8 deletions

View File

@@ -199,7 +199,7 @@ func (c *Cache) cleanPieces() {
rems := (c.filled-c.capacity)/c.pieceLength + 1
for _, p := range remPieces {
c.removePiece(p)
c.torrent.Piece(p.Id).UpdateCompletion()
//c.torrent.Piece(p.Id).UpdateCompletion() // safe call in Piece.Release()
rems--
if rems <= 0 {
utils.FreeOSMemGC()

View File

@@ -85,5 +85,5 @@ func (p *DiskPiece) Release() {
os.Remove(p.name)
p.piece.cache.torrent.Piece(p.piece.Id).SetPriority(torrent.PiecePriorityNone)
//p.piece.cache.torrent.Piece(p.piece.Id).SetPriority(torrent.PiecePriorityNone)
}

View File

@@ -70,5 +70,5 @@ func (p *MemPiece) Release() {
p.piece.Size = 0
p.piece.Complete = false
p.piece.cache.torrent.Piece(p.piece.Id).SetPriority(torrent.PiecePriorityNone)
//p.piece.cache.torrent.Piece(p.piece.Id).SetPriority(torrent.PiecePriorityNone)
}

View File

@@ -73,9 +73,9 @@ func (p *Piece) Release() {
} else {
p.dPiece.Release()
}
// if !p.cache.isClosed {
// p.cache.torrent.Piece(p.Id).SetPriority(torrent.PiecePriorityNone)
// // fix remove pieces hash
// p.cache.torrent.Piece(p.Id).UpdateCompletion()
// }
if !p.cache.isClosed {
p.cache.torrent.Piece(p.Id).SetPriority(torrent.PiecePriorityNone)
// fix remove pieces hash and rewind
p.cache.torrent.Piece(p.Id).UpdateCompletion()
}
}