diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-12-20 17:39:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-20 17:39:45 +0100 |
commit | fcd48db4d24f6dba4fb2652d72aa0d86e167aa0c (patch) | |
tree | a0aa3c847b8a5bb1ea47bf9895136998b95a9519 /vendor/github.com/vbauerster/mpb/v4/proxyreader.go | |
parent | e33d7e9fab9974c8c13868e7434f78feab7508af (diff) | |
parent | 50ece79387dcf6c748e3ae1bd6a7067059c0dfe3 (diff) | |
download | podman-fcd48db4d24f6dba4fb2652d72aa0d86e167aa0c.tar.gz podman-fcd48db4d24f6dba4fb2652d72aa0d86e167aa0c.tar.bz2 podman-fcd48db4d24f6dba4fb2652d72aa0d86e167aa0c.zip |
Merge pull request #4708 from containers/dependabot/go_modules/github.com/containers/image/v5-5.1.0
build(deps): bump github.com/containers/image/v5 from 5.0.0 to 5.1.0
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v4/proxyreader.go')
-rw-r--r-- | vendor/github.com/vbauerster/mpb/v4/proxyreader.go | 45 |
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 +} |