summaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/v4/proxyreader.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2019-12-19 13:29:25 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2019-12-20 09:30:47 -0500
commit50ece79387dcf6c748e3ae1bd6a7067059c0dfe3 (patch)
tree6b30c4f66f7be315ff2257447be3818be98fb50f /vendor/github.com/vbauerster/mpb/v4/proxyreader.go
parenta359ca0d1825859dd8b7c1384f11d703ec6625b4 (diff)
downloadpodman-50ece79387dcf6c748e3ae1bd6a7067059c0dfe3.tar.gz
podman-50ece79387dcf6c748e3ae1bd6a7067059c0dfe3.tar.bz2
podman-50ece79387dcf6c748e3ae1bd6a7067059c0dfe3.zip
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>
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v4/proxyreader.go')
-rw-r--r--vendor/github.com/vbauerster/mpb/v4/proxyreader.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v4/proxyreader.go b/vendor/github.com/vbauerster/mpb/v4/proxyreader.go
new file mode 100644
index 000000000..736142412
--- /dev/null
+++ b/vendor/github.com/vbauerster/mpb/v4/proxyreader.go
@@ -0,0 +1,45 @@
+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
+}