]> Sergey Matveev's repositories - btrtrc.git/commitdiff
If we fail to write to a piece, check its completion state
authorMatt Joiner <anacrolix@gmail.com>
Sun, 3 Apr 2016 06:36:57 +0000 (16:36 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 3 Apr 2016 06:36:57 +0000 (16:36 +1000)
client.go
torrent.go

index 00c2e27b5284d217cbc2d64e97255ebd125519e0..751fb45ddbc16d55bdc04e5afd746340e63edb63 100644 (file)
--- a/client.go
+++ b/client.go
@@ -2293,7 +2293,7 @@ func (me *Client) downloadedChunk(t *torrent, c *connection, msg *pp.Message) {
        if err != nil {
                log.Printf("%s: error writing chunk %v: %s", t, req, err)
                t.pendRequest(req)
-               // t.updatePiecePriority(msg.Index)
+               t.updatePieceCompletion(int(msg.Index))
                return
        }
 
index a7aa57e0d65cc88e22244cd4e0da5448b4be29d0..a3769cbcdd237dc6b65f38c54298d3180dfc5770 100644 (file)
@@ -1025,7 +1025,12 @@ func (t *torrent) putPieceInclination(pi []int) {
 }
 
 func (t *torrent) updatePieceCompletion(piece int) {
-       t.completedPieces.Set(piece, t.pieceCompleteUncached(piece))
+       pcu := t.pieceCompleteUncached(piece)
+       changed := t.completedPieces.Get(piece) != pcu
+       t.completedPieces.Set(piece, pcu)
+       if changed {
+               t.pieceChanged(piece)
+       }
 }
 
 // Non-blocking read. Client lock is not required.