Skip to content

Commit 7562e91

Browse files
committed
no writer in progress
1 parent e7ea8db commit 7562e91

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

internal/progress/progress.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,21 @@ import (
1111

1212
type Progress struct {
1313
r io.Reader
14-
w io.Writer
1514
offset int64
1615
size int64
1716
prefix string
1817
counter *ratecounter.RateCounter
1918
ticker *time.Ticker
2019
}
2120

22-
func New(rw io.Reader, offset, size int64, prefix string) *Progress {
23-
p := &Progress{
21+
func New(r io.Reader, offset, size int64, prefix string) *Progress {
22+
return &Progress{
23+
r: r,
2424
offset: offset,
2525
size: size,
2626
prefix: prefix,
2727
counter: ratecounter.NewRateCounter(time.Second),
2828
}
29-
if r, ok := rw.(io.Reader); ok {
30-
p.r = r
31-
}
32-
if w, ok := rw.(io.Writer); ok {
33-
p.w = w
34-
}
35-
return p
3629
}
3730

3831
func (r *Progress) Read(p []byte) (int, error) {
@@ -42,13 +35,6 @@ func (r *Progress) Read(p []byte) (int, error) {
4235
return n, err
4336
}
4437

45-
func (r *Progress) Write(p []byte) (int, error) {
46-
n, err := r.w.Write(p)
47-
r.counter.Incr(int64(n))
48-
atomic.AddInt64(&r.offset, int64(n))
49-
return n, err
50-
}
51-
5238
func (r *Progress) Start() {
5339
r.ticker = time.NewTicker(time.Second)
5440
go r.run()

0 commit comments

Comments
 (0)