Skip to content

Commit

Permalink
fixed completed bytes count
Browse files Browse the repository at this point in the history
  • Loading branch information
dvovk committed Aug 22, 2024
1 parent a1b13ba commit aa3478a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 0 additions & 3 deletions t.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,6 @@ func (t *Torrent) DownloadPieces(begin, end pieceIndex) {
cs.pieceHashed(size)
})
storage.MarkComplete(false)
t.allStats(func(cs *ConnStats) {
cs.pieceCompleted(size)
})
t.updatePieceCompletion(piece.index, true)
return nil
}
Expand Down
12 changes: 7 additions & 5 deletions torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,12 @@ func (t *Torrent) updatePieceCompletion(piece pieceIndex, lock bool) bool {
x := uint32(piece)

if complete {
if !t._completedPieces.Contains(x) {
t.allStats(func(cs *ConnStats) {
cs.pieceCompleted(p.Info().Length())
})
}

t._completedPieces.Add(x)
t.openNewConns(false)
} else {
Expand Down Expand Up @@ -2645,11 +2651,7 @@ func (t *Torrent) pieceHashed(piece pieceIndex, passed bool, hashIoErr error) {

err := p.Storage().MarkComplete(!hasDirtyChunks)

if err == nil {
t.allStats(func(cs *ConnStats) {
cs.pieceCompleted(int64(p.length(true)))
})
} else {
if err != nil {
t.logger.Levelf(log.Warning, "%T: error marking piece complete %d: %s", t.storage, piece, err)
}

Expand Down

0 comments on commit aa3478a

Please sign in to comment.