File tree Expand file tree Collapse file tree 1 file changed +3
-17
lines changed
Expand file tree Collapse file tree 1 file changed +3
-17
lines changed Original file line number Diff line number Diff line change @@ -11,28 +11,21 @@ import (
1111
1212type 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
3831func (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-
5238func (r * Progress ) Start () {
5339 r .ticker = time .NewTicker (time .Second )
5440 go r .run ()
You can’t perform that action at this time.
0 commit comments