Skip to content

Commit

Permalink
log an error and bail out when receiving a piece we have already rece…
Browse files Browse the repository at this point in the history
…ived instead of aborting
  • Loading branch information
bsergean committed Oct 19, 2021
1 parent e27ba11 commit 1a158d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions torrent/torrent_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package torrent

import (
"errors"
"fmt"

"github.com/cenkalti/rain/internal/peer"
"github.com/cenkalti/rain/internal/peerprotocol"
Expand Down Expand Up @@ -41,7 +40,8 @@ func (t *torrent) handlePieceWriteDone(pw *piecewriter.PieceWriter) {

pw.Piece.Done = true
if t.bitfield.Test(pw.Piece.Index) {
panic(fmt.Sprintf("already have the piece #%d", pw.Piece.Index))
t.log.Errorf("already have the piece #%d", pw.Piece.Index)
return
}
t.mBitfield.Lock()
t.bitfield.Set(pw.Piece.Index)
Expand Down

0 comments on commit 1a158d7

Please sign in to comment.