Skip to content

Commit

Permalink
fix: add traffic (#2634)
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Ma <[email protected]>
  • Loading branch information
jim3ma authored Aug 15, 2023
1 parent 5fb1ef9 commit 554b27c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client/daemon/peer/piece_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (pm *pieceManager) processPieceFromSource(pt Task,
pt.Log().Debugf("piece %d calculate digest", pieceNum)
reader, _ = digest.NewReader(digest.AlgorithmMD5, reader, digest.WithLogger(pt.Log()))
}
var n int64

result.Size, err = pt.GetStorage().WritePiece(
pt.Context(),
&storage.WritePieceRequest{
Expand All @@ -285,11 +285,11 @@ func (pm *pieceManager) processPieceFromSource(pt Task,
})

result.FinishTime = time.Now().UnixNano()
if n > 0 {
pt.AddTraffic(uint64(n))
if result.Size > 0 {
pt.AddTraffic(uint64(result.Size))
}
if err != nil {
pt.Log().Errorf("put piece to storage failed, piece num: %d, wrote: %d, error: %s", pieceNum, n, err)
pt.Log().Errorf("put piece to storage failed, piece num: %d, wrote: %d, error: %s", pieceNum, result.Size, err)
return
}
if pm.calculateDigest {
Expand Down

0 comments on commit 554b27c

Please sign in to comment.