client.go | 10 ++++++++-- diff --git a/client.go b/client.go index cddb442f305b0303a627bc6723be6f363e695879..7b3a8967513fddae41f0894bb7769e5347fe4e9e 100644 --- a/client.go +++ b/client.go @@ -920,8 +920,14 @@ } } func (me *Client) peerGotPiece(t *torrent, c *connection, piece int) { - for piece >= len(c.PeerPieces) { - c.PeerPieces = append(c.PeerPieces, false) + if t.haveInfo() { + if c.PeerPieces == nil { + c.PeerPieces = make([]bool, t.NumPieces()) + } + } else { + for piece >= len(c.PeerPieces) { + c.PeerPieces = append(c.PeerPieces, false) + } } c.PeerPieces[piece] = true if t.wantPiece(piece) {