We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6b0fcc5 commit 5bb8135Copy full SHA for 5bb8135
defs/bytes_counter.go
@@ -6,14 +6,14 @@ import (
6
"fmt"
7
"io"
8
"log"
9
- "math"
10
"sync"
11
"time"
12
)
13
14
// BytesCounter implements io.Reader and io.Writer interface, for counting bytes being read/written in HTTP requests
15
type BytesCounter struct {
16
start time.Time
+ pos int
17
total int
18
payload []byte
19
reader io.ReadSeeker
@@ -43,8 +43,9 @@ func (c *BytesCounter) Read(p []byte) (int, error) {
43
n, err := c.reader.Read(p)
44
c.lock.Lock()
45
c.total += n
46
-
47
- if math.Mod(float64(c.total), uploadSize) == 0 {
+ c.pos += n
+ if c.pos == uploadSize {
48
+ c.pos = 0
49
c.resetReader()
50
}
51
c.lock.Unlock()
0 commit comments