From: Matt Joiner Date: Sun, 3 Apr 2016 06:36:57 +0000 (+1000) Subject: If we fail to write to a piece, check its completion state X-Git-Tag: v1.0.0~800 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=bc8fb2a1657d9a3725fdaba89264d052640710c5;p=btrtrc.git If we fail to write to a piece, check its completion state --- diff --git a/client.go b/client.go index 00c2e27b..751fb45d 100644 --- 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 } diff --git a/torrent.go b/torrent.go index a7aa57e0..a3769cbc 100644 --- a/torrent.go +++ b/torrent.go @@ -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.