From b0bd2a776a559a88e22591e2b4262e16c63413f4 Mon Sep 17 00:00:00 2001 From: liwei Date: Fri, 28 Feb 2020 19:05:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20piece=E4=B8=8B=E8=BD=BD=E6=AD=BB?= =?UTF-8?q?=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocol/bt/torrent/peer_conn.go | 2 ++ protocol/bt/torrent/torrent.go | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protocol/bt/torrent/peer_conn.go b/protocol/bt/torrent/peer_conn.go index 23a29d9b..2f800a07 100644 --- a/protocol/bt/torrent/peer_conn.go +++ b/protocol/bt/torrent/peer_conn.go @@ -212,6 +212,8 @@ func (pc *peerConn) downloadPiece(index int) error { select { case pc.blockQueueCh <- nil: break + case err := <-pc.downloadedCh: + return err case err := <-pc.disconnectCh: return err } diff --git a/protocol/bt/torrent/torrent.go b/protocol/bt/torrent/torrent.go index 6f69627d..8ce928fd 100644 --- a/protocol/bt/torrent/torrent.go +++ b/protocol/bt/torrent/torrent.go @@ -2,7 +2,6 @@ package torrent import ( "errors" - "fmt" "github.com/monkeyWie/gopeed/protocol/bt/metainfo" log "github.com/sirupsen/logrus" "time" @@ -43,7 +42,6 @@ func (t *Torrent) Download(path string) { index := t.pieces.getReady() // 没有待下载的piece了 if index == -1 { - fmt.Println("wait piece") if <-t.completeCh { // 下载完成 break