From df3de3111bf7423d450a9fd3f4a7e10ba8f1f765 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Tue, 8 Aug 2017 17:18:34 -0400 Subject: [PATCH] dont continue downloading --- src/xd/lib/bittorrent/swarm/piece.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/xd/lib/bittorrent/swarm/piece.go b/src/xd/lib/bittorrent/swarm/piece.go index c5c024e..e4aec1f 100644 --- a/src/xd/lib/bittorrent/swarm/piece.go +++ b/src/xd/lib/bittorrent/swarm/piece.go @@ -164,6 +164,10 @@ func (pt *pieceTracker) nextRequestForDownload(remote *bittorrent.Bitfield) (r * idx := pt.pendingPiece(remote) cp, has := pt.requests[idx] if !has { + if pt.st.Bitfield().Has(idx) { + pt.mtx.Unlock() + return + } cp = pt.newPiece(idx) pt.requests[idx] = cp }