]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add Piece.UpdateCompletion() method
authorCraig Campbell <iamcraigcampbell@gmail.com>
Sun, 5 Jan 2020 02:12:02 +0000 (21:12 -0500)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 4 Apr 2020 22:57:58 +0000 (08:57 +1000)
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.

piece.go

index d2211aa0ed040d22dbc351d369840fce59b31757..f112e0bd262c4f194628a54f94af8aa528258090 100644 (file)
--- a/piece.go
+++ b/piece.go
@@ -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