Add Piece.UpdateCompletion() method

This should be all that is needed to handle pieces that are evicted or
removed from storage if you are using a storage implementation such as an LRU
cache.
This commit is contained in:
Craig Campbell 2020-01-04 21:12:02 -05:00 committed by Matt Joiner
parent c435d713c4
commit 6920298770
1 changed files with 6 additions and 0 deletions

View File

@ -239,6 +239,12 @@ func (p *Piece) uncachedPriority() (ret piecePriority) {
return
}
func (p *Piece) UpdateCompletion() {
p.t.cl.lock()
defer p.t.cl.unlock()
p.t.updatePieceCompletion(p.index)
}
func (p *Piece) completion() (ret storage.Completion) {
ret.Complete = p.t.pieceComplete(p.index)
ret.Ok = p.storageCompletionOk