Files
podman/vendor/github.com/vbauerster/mpb/v4/proxyreader.go
Daniel J Walsh 50ece79387 build(deps): bump github.com/containers/image/v5 from 5.0.0 to 5.1.0
Bumps [github.com/containers/image/v5](https://github.com/containers/image) from 5.0.0 to 5.1.0.
- [Release notes](https://github.com/containers/image/releases)
- [Commits](https://github.com/containers/image/compare/v5.0.0...v5.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-12-20 09:30:47 -05:00

46 lines
694 B
Go

package mpb
import (
"io"
"time"
)
type proxyReader struct {
io.ReadCloser
bar *Bar
iT time.Time
}
func (prox *proxyReader) Read(p []byte) (n int, err error) {
n, err = prox.ReadCloser.Read(p)
if n > 0 {
prox.bar.IncrBy(n, time.Since(prox.iT))
prox.iT = time.Now()
}
if err == io.EOF {
go func() {
prox.bar.SetTotal(0, true)
}()
}
return
}
type proxyWriterTo struct {
*proxyReader
wt io.WriterTo
}
func (prox *proxyWriterTo) WriteTo(w io.Writer) (n int64, err error) {
n, err = prox.wt.WriteTo(w)
if n > 0 {
prox.bar.IncrInt64(n, time.Since(prox.iT))
prox.iT = time.Now()
}
if err == io.EOF {
go func() {
prox.bar.SetTotal(0, true)
}()
}
return
}