summaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/v7
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-08-26 13:21:26 +0000
committerGitHub <noreply@github.com>2021-08-26 13:21:26 +0000
commitf5ce02b227f43feb7a02b09890facf198448621e (patch)
treef7ff84b1f21b6b7a31b166ce8ad77caf0e456b03 /vendor/github.com/vbauerster/mpb/v7
parent6f1faf36da9482c1cc99814772d16125fe9a4e36 (diff)
downloadpodman-f5ce02b227f43feb7a02b09890facf198448621e.tar.gz
podman-f5ce02b227f43feb7a02b09890facf198448621e.tar.bz2
podman-f5ce02b227f43feb7a02b09890facf198448621e.zip
Bump github.com/containers/image/v5 from 5.15.2 to 5.16.0
Bumps [github.com/containers/image/v5](https://github.com/containers/image) from 5.15.2 to 5.16.0. - [Release notes](https://github.com/containers/image/releases) - [Commits](https://github.com/containers/image/compare/v5.15.2...v5.16.0) --- updated-dependencies: - dependency-name: github.com/containers/image/v5 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v7')
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/README.md2
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/bar.go116
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/bar_filler_bar.go150
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/container_option.go6
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/cwriter/writer.go10
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/cwriter/writer_windows.go4
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/go.mod2
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/go.sum4
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/internal/percentage.go4
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/progress.go46
10 files changed, 210 insertions, 134 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v7/README.md b/vendor/github.com/vbauerster/mpb/v7/README.md
index d0560d799..90d4fe639 100644
--- a/vendor/github.com/vbauerster/mpb/v7/README.md
+++ b/vendor/github.com/vbauerster/mpb/v7/README.md
@@ -84,7 +84,7 @@ func main() {
// replace ETA decorator with "done" message, OnComplete event
decor.OnComplete(
// ETA decorator with ewma age of 60
- decor.EwmaETA(decor.ET_STYLE_GO, 60), "done",
+ decor.EwmaETA(decor.ET_STYLE_GO, 60, decor.WCSyncWidth), "done",
),
),
)
diff --git a/vendor/github.com/vbauerster/mpb/v7/bar.go b/vendor/github.com/vbauerster/mpb/v7/bar.go
index ed6c73eda..ca191cf39 100644
--- a/vendor/github.com/vbauerster/mpb/v7/bar.go
+++ b/vendor/github.com/vbauerster/mpb/v7/bar.go
@@ -20,21 +20,18 @@ type Bar struct {
priority int // used by heap
index int // used by heap
- extendedLines int
toShutdown bool
toDrop bool
noPop bool
hasEwmaDecorators bool
operateState chan func(*bState)
- frameCh chan io.Reader
- syncTableCh chan [][]chan int
- completed chan bool
+ frameCh chan *frame
// cancel is called either by user or on complete event
cancel func()
// done is closed after cacheState is assigned
done chan struct{}
- // cacheState is populated, right after close(shutdown)
+ // cacheState is populated, right after close(b.done)
cacheState *bState
container *Progress
@@ -77,6 +74,11 @@ type bState struct {
debugOut io.Writer
}
+type frame struct {
+ reader io.Reader
+ lines int
+}
+
func newBar(container *Progress, bs *bState) *Bar {
logPrefix := fmt.Sprintf("%sbar#%02d ", container.dlogger.Prefix(), bs.id)
ctx, cancel := context.WithCancel(container.ctx)
@@ -87,9 +89,7 @@ func newBar(container *Progress, bs *bState) *Bar {
toDrop: bs.dropOnComplete,
noPop: bs.noPop,
operateState: make(chan func(*bState)),
- frameCh: make(chan io.Reader, 1),
- syncTableCh: make(chan [][]chan int, 1),
- completed: make(chan bool, 1),
+ frameCh: make(chan *frame, 1),
done: make(chan struct{}),
cancel: cancel,
dlogger: log.New(bs.debugOut, logPrefix, log.Lshortfile),
@@ -145,6 +145,7 @@ func (b *Bar) SetRefill(amount int64) {
// TraverseDecorators traverses all available decorators and calls cb func on each.
func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
+ done := make(chan struct{})
select {
case b.operateState <- func(s *bState) {
for _, decorators := range [...][]decor.Decorator{
@@ -155,7 +156,9 @@ func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
cb(extractBaseDecorator(d))
}
}
+ close(done)
}:
+ <-done
case <-b.done:
}
}
@@ -174,7 +177,7 @@ func (b *Bar) SetTotal(total int64, triggerComplete bool) {
if s.triggerComplete && !s.completed {
s.current = s.total
s.completed = true
- go b.refreshTillShutdown()
+ go b.forceRefreshIfLastUncompleted()
}
}:
case <-b.done:
@@ -192,7 +195,7 @@ func (b *Bar) SetCurrent(current int64) {
if s.triggerComplete && s.current >= s.total {
s.current = s.total
s.completed = true
- go b.refreshTillShutdown()
+ go b.forceRefreshIfLastUncompleted()
}
}:
case <-b.done:
@@ -219,7 +222,7 @@ func (b *Bar) IncrInt64(n int64) {
if s.triggerComplete && s.current >= s.total {
s.current = s.total
s.completed = true
- go b.refreshTillShutdown()
+ go b.forceRefreshIfLastUncompleted()
}
}:
case <-b.done:
@@ -258,32 +261,49 @@ func (b *Bar) DecoratorAverageAdjust(start time.Time) {
// priority, i.e. bar will be on top. If you don't need to set priority
// dynamically, better use BarPriority option.
func (b *Bar) SetPriority(priority int) {
- select {
- case <-b.done:
- default:
- b.container.setBarPriority(b, priority)
- }
+ b.container.UpdateBarPriority(b, priority)
}
-// Abort interrupts bar's running goroutine. Call this, if you'd like
-// to stop/remove bar before completion event. It has no effect after
-// completion event. If drop is true bar will be removed as well.
+// Abort interrupts bar's running goroutine. Abort won't be engaged
+// if bar is already in complete state. If drop is true bar will be
+// removed as well.
func (b *Bar) Abort(drop bool) {
select {
- case <-b.done:
- default:
+ case b.operateState <- func(s *bState) {
+ if s.completed == true {
+ return
+ }
if drop {
b.container.dropBar(b)
+ b.cancel()
+ return
}
- b.cancel()
+ go func() {
+ var uncompleted int
+ b.container.traverseBars(func(bar *Bar) bool {
+ if b != bar && !bar.Completed() {
+ uncompleted++
+ return false
+ }
+ return true
+ })
+ if uncompleted == 0 {
+ b.container.refreshCh <- time.Now()
+ }
+ b.cancel()
+ }()
+ }:
+ <-b.done
+ case <-b.done:
}
}
// Completed reports whether the bar is in completed state.
func (b *Bar) Completed() bool {
+ result := make(chan bool)
select {
- case b.operateState <- func(s *bState) { b.completed <- s.completed }:
- return <-b.completed
+ case b.operateState <- func(s *bState) { result <- s.completed }:
+ return <-result
case <-b.done:
return true
}
@@ -296,12 +316,12 @@ func (b *Bar) serve(ctx context.Context, s *bState) {
case op := <-b.operateState:
op(s)
case <-ctx.Done():
- b.cacheState = s
- close(b.done)
// Notifying decorators about shutdown event
for _, sl := range s.shutdownListeners {
sl.Shutdown()
}
+ b.cacheState = s
+ close(b.done)
return
}
}
@@ -319,17 +339,15 @@ func (b *Bar) render(tw int) {
b.toShutdown = !b.toShutdown
b.recoveredPanic = p
}
- frame, lines := s.extender(nil, s.reqWidth, stat)
- b.extendedLines = lines
- b.frameCh <- frame
+ reader, lines := s.extender(nil, s.reqWidth, stat)
+ b.frameCh <- &frame{reader, lines + 1}
b.dlogger.Println(p)
}
s.completeFlushed = s.completed
}()
- frame, lines := s.extender(s.draw(stat), s.reqWidth, stat)
- b.extendedLines = lines
+ reader, lines := s.extender(s.draw(stat), s.reqWidth, stat)
b.toShutdown = s.completed && !s.completeFlushed
- b.frameCh <- frame
+ b.frameCh <- &frame{reader, lines + 1}
}:
case <-b.done:
s := b.cacheState
@@ -338,9 +356,8 @@ func (b *Bar) render(tw int) {
if b.recoveredPanic == nil {
r = s.draw(stat)
}
- frame, lines := s.extender(r, s.reqWidth, stat)
- b.extendedLines = lines
- b.frameCh <- frame
+ reader, lines := s.extender(r, s.reqWidth, stat)
+ b.frameCh <- &frame{reader, lines + 1}
}
}
@@ -359,31 +376,42 @@ func (b *Bar) subscribeDecorators() {
shutdownListeners = append(shutdownListeners, d)
}
})
+ b.hasEwmaDecorators = len(ewmaDecorators) != 0
select {
case b.operateState <- func(s *bState) {
s.averageDecorators = averageDecorators
s.ewmaDecorators = ewmaDecorators
s.shutdownListeners = shutdownListeners
}:
- b.hasEwmaDecorators = len(ewmaDecorators) != 0
case <-b.done:
}
}
-func (b *Bar) refreshTillShutdown() {
- for {
- select {
- case b.container.refreshCh <- time.Now():
- case <-b.done:
- return
+func (b *Bar) forceRefreshIfLastUncompleted() {
+ var uncompleted int
+ b.container.traverseBars(func(bar *Bar) bool {
+ if b != bar && !bar.Completed() {
+ uncompleted++
+ return false
+ }
+ return true
+ })
+ if uncompleted == 0 {
+ for {
+ select {
+ case b.container.refreshCh <- time.Now():
+ case <-b.done:
+ return
+ }
}
}
}
func (b *Bar) wSyncTable() [][]chan int {
+ result := make(chan [][]chan int)
select {
- case b.operateState <- func(s *bState) { b.syncTableCh <- s.wSyncTable() }:
- return <-b.syncTableCh
+ case b.operateState <- func(s *bState) { result <- s.wSyncTable() }:
+ return <-result
case <-b.done:
return b.cacheState.wSyncTable()
}
diff --git a/vendor/github.com/vbauerster/mpb/v7/bar_filler_bar.go b/vendor/github.com/vbauerster/mpb/v7/bar_filler_bar.go
index e30d4921c..80b210455 100644
--- a/vendor/github.com/vbauerster/mpb/v7/bar_filler_bar.go
+++ b/vendor/github.com/vbauerster/mpb/v7/bar_filler_bar.go
@@ -26,15 +26,17 @@ type BarStyleComposer interface {
Filler(string) BarStyleComposer
Refiller(string) BarStyleComposer
Padding(string) BarStyleComposer
- Tip(...string) BarStyleComposer
+ TipOnComplete(string) BarStyleComposer
+ Tip(frames ...string) BarStyleComposer
Reverse() BarStyleComposer
}
type bFiller struct {
components [components]*component
tip struct {
- count uint
- frames []*component
+ count uint
+ onComplete *component
+ frames []*component
}
flush func(dst io.Writer, filling, padding [][]byte)
}
@@ -45,25 +47,26 @@ type component struct {
}
type barStyle struct {
- lbound string
- rbound string
- filler string
- refiller string
- padding string
- tip []string
- rev bool
+ lbound string
+ rbound string
+ filler string
+ refiller string
+ padding string
+ tipOnComplete string
+ tipFrames []string
+ rev bool
}
// BarStyle constructs default bar style which can be altered via
// BarStyleComposer interface.
func BarStyle() BarStyleComposer {
return &barStyle{
- lbound: "[",
- rbound: "]",
- filler: "=",
- refiller: "+",
- padding: "-",
- tip: []string{">"},
+ lbound: "[",
+ rbound: "]",
+ filler: "=",
+ refiller: "+",
+ padding: "-",
+ tipFrames: []string{">"},
}
}
@@ -92,9 +95,14 @@ func (s *barStyle) Padding(padding string) BarStyleComposer {
return s
}
-func (s *barStyle) Tip(tip ...string) BarStyleComposer {
- if len(tip) != 0 {
- s.tip = append(s.tip[:0], tip...)
+func (s *barStyle) TipOnComplete(tip string) BarStyleComposer {
+ s.tipOnComplete = tip
+ return s
+}
+
+func (s *barStyle) Tip(frames ...string) BarStyleComposer {
+ if len(frames) != 0 {
+ s.tipFrames = append(s.tipFrames[:0], frames...)
}
return s
}
@@ -133,8 +141,12 @@ func (s *barStyle) Build() BarFiller {
width: runewidth.StringWidth(stripansi.Strip(s.padding)),
bytes: []byte(s.padding),
}
- bf.tip.frames = make([]*component, len(s.tip))
- for i, t := range s.tip {
+ bf.tip.onComplete = &component{
+ width: runewidth.StringWidth(stripansi.Strip(s.tipOnComplete)),
+ bytes: []byte(s.tipOnComplete),
+ }
+ bf.tip.frames = make([]*component, len(s.tipFrames))
+ for i, t := range s.tipFrames {
bf.tip.frames[i] = &component{
width: runewidth.StringWidth(stripansi.Strip(t)),
bytes: []byte(t),
@@ -146,64 +158,82 @@ func (s *barStyle) Build() BarFiller {
func (s *bFiller) Fill(w io.Writer, width int, stat decor.Statistics) {
width = internal.CheckRequestedWidth(width, stat.AvailableWidth)
brackets := s.components[iLbound].width + s.components[iRbound].width
- if width < brackets {
- return
- }
// don't count brackets as progress
width -= brackets
+ if width < 0 {
+ return
+ }
w.Write(s.components[iLbound].bytes)
defer w.Write(s.components[iRbound].bytes)
- curWidth := int(internal.PercentageRound(stat.Total, stat.Current, width))
- refWidth, filled := 0, curWidth
- filling := make([][]byte, 0, curWidth)
-
- if curWidth > 0 && curWidth != width {
- tipFrame := s.tip.frames[s.tip.count%uint(len(s.tip.frames))]
- filling = append(filling, tipFrame.bytes)
- curWidth -= tipFrame.width
- s.tip.count++
+ if width == 0 {
+ return
}
- if stat.Refill > 0 && curWidth > 0 {
- refWidth = int(internal.PercentageRound(stat.Total, int64(stat.Refill), width))
- if refWidth > curWidth {
- refWidth = curWidth
- }
- curWidth -= refWidth
+ var filling [][]byte
+ var padding [][]byte
+ var tip *component
+ var filled int
+ var refWidth int
+ curWidth := int(internal.PercentageRound(stat.Total, stat.Current, uint(width)))
+
+ if stat.Current >= stat.Total {
+ tip = s.tip.onComplete
+ } else {
+ tip = s.tip.frames[s.tip.count%uint(len(s.tip.frames))]
}
- for curWidth > 0 && curWidth >= s.components[iFiller].width {
- filling = append(filling, s.components[iFiller].bytes)
- curWidth -= s.components[iFiller].width
- if s.components[iFiller].width == 0 {
- break
- }
+ if curWidth > 0 {
+ filling = append(filling, tip.bytes)
+ filled += tip.width
+ s.tip.count++
}
- for refWidth > 0 && refWidth >= s.components[iRefiller].width {
- filling = append(filling, s.components[iRefiller].bytes)
- refWidth -= s.components[iRefiller].width
- if s.components[iRefiller].width == 0 {
- break
+ if stat.Refill > 0 {
+ refWidth = int(internal.PercentageRound(stat.Total, stat.Refill, uint(width)))
+ curWidth -= refWidth
+ refWidth += curWidth
+ }
+
+ for filled < curWidth {
+ if curWidth-filled >= s.components[iFiller].width {
+ filling = append(filling, s.components[iFiller].bytes)
+ if s.components[iFiller].width == 0 {
+ break
+ }
+ filled += s.components[iFiller].width
+ } else {
+ filling = append(filling, []byte("…"))
+ filled++
}
}
- filled -= curWidth + refWidth
- padWidth := width - filled
- padding := make([][]byte, 0, padWidth)
- for padWidth > 0 && padWidth >= s.components[iPadding].width {
- padding = append(padding, s.components[iPadding].bytes)
- padWidth -= s.components[iPadding].width
- if s.components[iPadding].width == 0 {
- break
+ for filled < refWidth {
+ if refWidth-filled >= s.components[iRefiller].width {
+ filling = append(filling, s.components[iRefiller].bytes)
+ if s.components[iRefiller].width == 0 {
+ break
+ }
+ filled += s.components[iRefiller].width
+ } else {
+ filling = append(filling, []byte("…"))
+ filled++
}
}
+ padWidth := width - filled
for padWidth > 0 {
- padding = append(padding, []byte("…"))
- padWidth--
+ if padWidth >= s.components[iPadding].width {
+ padding = append(padding, s.components[iPadding].bytes)
+ if s.components[iPadding].width == 0 {
+ break
+ }
+ padWidth -= s.components[iPadding].width
+ } else {
+ padding = append(padding, []byte("…"))
+ padWidth--
+ }
}
s.flush(w, filling, padding)
diff --git a/vendor/github.com/vbauerster/mpb/v7/container_option.go b/vendor/github.com/vbauerster/mpb/v7/container_option.go
index e4254f662..a858c3c51 100644
--- a/vendor/github.com/vbauerster/mpb/v7/container_option.go
+++ b/vendor/github.com/vbauerster/mpb/v7/container_option.go
@@ -62,7 +62,11 @@ func WithRenderDelay(ch <-chan struct{}) ContainerOption {
// have been rendered.
func WithShutdownNotifier(ch chan struct{}) ContainerOption {
return func(s *pState) {
- s.shutdownNotifier = ch
+ select {
+ case <-ch:
+ default:
+ s.shutdownNotifier = ch
+ }
}
}
diff --git a/vendor/github.com/vbauerster/mpb/v7/cwriter/writer.go b/vendor/github.com/vbauerster/mpb/v7/cwriter/writer.go
index 1ade54761..925c8b1dc 100644
--- a/vendor/github.com/vbauerster/mpb/v7/cwriter/writer.go
+++ b/vendor/github.com/vbauerster/mpb/v7/cwriter/writer.go
@@ -22,7 +22,7 @@ const (
type Writer struct {
out io.Writer
buf bytes.Buffer
- lineCount int
+ lines int
fd int
isTerminal bool
}
@@ -38,15 +38,15 @@ func New(out io.Writer) *Writer {
}
// Flush flushes the underlying buffer.
-func (w *Writer) Flush(lineCount int) (err error) {
+func (w *Writer) Flush(lines int) (err error) {
// some terminals interpret 'cursor up 0' as 'cursor up 1'
- if w.lineCount > 0 {
+ if w.lines > 0 {
err = w.clearLines()
if err != nil {
return
}
}
- w.lineCount = lineCount
+ w.lines = lines
_, err = w.buf.WriteTo(w.out)
return
}
@@ -78,7 +78,7 @@ func (w *Writer) GetWidth() (int, error) {
func (w *Writer) ansiCuuAndEd() (err error) {
buf := make([]byte, 8)
- buf = strconv.AppendInt(buf[:copy(buf, escOpen)], int64(w.lineCount), 10)
+ buf = strconv.AppendInt(buf[:copy(buf, escOpen)], int64(w.lines), 10)
_, err = w.out.Write(append(buf, cuuAndEd...))
return
}
diff --git a/vendor/github.com/vbauerster/mpb/v7/cwriter/writer_windows.go b/vendor/github.com/vbauerster/mpb/v7/cwriter/writer_windows.go
index 1a69c81ac..8f99dbe32 100644
--- a/vendor/github.com/vbauerster/mpb/v7/cwriter/writer_windows.go
+++ b/vendor/github.com/vbauerster/mpb/v7/cwriter/writer_windows.go
@@ -26,7 +26,7 @@ func (w *Writer) clearLines() error {
return err
}
- info.CursorPosition.Y -= int16(w.lineCount)
+ info.CursorPosition.Y -= int16(w.lines)
if info.CursorPosition.Y < 0 {
info.CursorPosition.Y = 0
}
@@ -40,7 +40,7 @@ func (w *Writer) clearLines() error {
X: info.Window.Left,
Y: info.CursorPosition.Y,
}
- count := uint32(info.Size.X) * uint32(w.lineCount)
+ count := uint32(info.Size.X) * uint32(w.lines)
_, _, _ = procFillConsoleOutputCharacter.Call(
uintptr(w.fd),
uintptr(' '),
diff --git a/vendor/github.com/vbauerster/mpb/v7/go.mod b/vendor/github.com/vbauerster/mpb/v7/go.mod
index 22a2c651c..7b177d0db 100644
--- a/vendor/github.com/vbauerster/mpb/v7/go.mod
+++ b/vendor/github.com/vbauerster/mpb/v7/go.mod
@@ -4,7 +4,7 @@ require (
github.com/VividCortex/ewma v1.2.0
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/mattn/go-runewidth v0.0.13
- golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
+ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e
)
go 1.14
diff --git a/vendor/github.com/vbauerster/mpb/v7/go.sum b/vendor/github.com/vbauerster/mpb/v7/go.sum
index 59051bd7b..45584e0bf 100644
--- a/vendor/github.com/vbauerster/mpb/v7/go.sum
+++ b/vendor/github.com/vbauerster/mpb/v7/go.sum
@@ -6,5 +6,5 @@ github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
-golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio=
-golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
+golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/vendor/github.com/vbauerster/mpb/v7/internal/percentage.go b/vendor/github.com/vbauerster/mpb/v7/internal/percentage.go
index a8ef8be12..4bc36f5ba 100644
--- a/vendor/github.com/vbauerster/mpb/v7/internal/percentage.go
+++ b/vendor/github.com/vbauerster/mpb/v7/internal/percentage.go
@@ -3,7 +3,7 @@ package internal
import "math"
// Percentage is a helper function, to calculate percentage.
-func Percentage(total, current int64, width int) float64 {
+func Percentage(total, current int64, width uint) float64 {
if total <= 0 {
return 0
}
@@ -14,6 +14,6 @@ func Percentage(total, current int64, width int) float64 {
}
// PercentageRound same as Percentage but with math.Round.
-func PercentageRound(total, current int64, width int) float64 {
+func PercentageRound(total, current int64, width uint) float64 {
return math.Round(Percentage(total, current, width))
}
diff --git a/vendor/github.com/vbauerster/mpb/v7/progress.go b/vendor/github.com/vbauerster/mpb/v7/progress.go
index b2017f3f0..c60c65694 100644
--- a/vendor/github.com/vbauerster/mpb/v7/progress.go
+++ b/vendor/github.com/vbauerster/mpb/v7/progress.go
@@ -19,7 +19,7 @@ import (
const (
// default RefreshRate
- prr = 120 * time.Millisecond
+ prr = 150 * time.Millisecond
)
// Progress represents a container that renders one or more progress
@@ -157,27 +157,40 @@ func (p *Progress) dropBar(b *Bar) {
}
}
-func (p *Progress) setBarPriority(b *Bar, priority int) {
+func (p *Progress) traverseBars(cb func(b *Bar) bool) {
+ done := make(chan struct{})
select {
case p.operateState <- func(s *pState) {
- if b.index < 0 {
- return
+ for i := 0; i < s.bHeap.Len(); i++ {
+ bar := s.bHeap[i]
+ if !cb(bar) {
+ break
+ }
}
- b.priority = priority
- heap.Fix(&s.bHeap, b.index)
+ close(done)
}:
+ <-done
case <-p.done:
}
}
// UpdateBarPriority same as *Bar.SetPriority(int).
func (p *Progress) UpdateBarPriority(b *Bar, priority int) {
- p.setBarPriority(b, priority)
+ select {
+ case p.operateState <- func(s *pState) {
+ if b.index < 0 {
+ return
+ }
+ b.priority = priority
+ heap.Fix(&s.bHeap, b.index)
+ }:
+ case <-p.done:
+ }
}
// BarCount returns bars count.
func (p *Progress) BarCount() int {
- result := make(chan int, 1)
+ result := make(chan int)
select {
case p.operateState <- func(s *pState) { result <- s.bHeap.Len() }:
return <-result
@@ -222,7 +235,7 @@ func (p *Progress) serve(s *pState, cw *cwriter.Writer) {
p.dlogger.Println(err)
}
case <-s.shutdownNotifier:
- if s.heapUpdated {
+ for s.heapUpdated {
if err := s.render(cw); err != nil {
p.dlogger.Println(err)
}
@@ -291,11 +304,12 @@ func (s *pState) render(cw *cwriter.Writer) error {
}
func (s *pState) flush(cw *cwriter.Writer) error {
- var lineCount int
- bm := make(map[*Bar]struct{}, s.bHeap.Len())
+ var totalLines int
+ bm := make(map[*Bar]int, s.bHeap.Len())
for s.bHeap.Len() > 0 {
b := heap.Pop(&s.bHeap).(*Bar)
- cw.ReadFrom(<-b.frameCh)
+ frame := <-b.frameCh
+ cw.ReadFrom(frame.reader)
if b.toShutdown {
if b.recoveredPanic != nil {
s.barShutdownQueue = append(s.barShutdownQueue, b)
@@ -308,8 +322,8 @@ func (s *pState) flush(cw *cwriter.Writer) error {
}()
}
}
- lineCount += b.extendedLines + 1
- bm[b] = struct{}{}
+ bm[b] = frame.lines
+ totalLines += frame.lines
}
for _, b := range s.barShutdownQueue {
@@ -320,7 +334,7 @@ func (s *pState) flush(cw *cwriter.Writer) error {
b.toDrop = true
}
if s.popCompleted && !b.noPop {
- lineCount -= b.extendedLines + 1
+ totalLines -= bm[b]
b.toDrop = true
}
if b.toDrop {
@@ -335,7 +349,7 @@ func (s *pState) flush(cw *cwriter.Writer) error {
heap.Push(&s.bHeap, b)
}
- return cw.Flush(lineCount)
+ return cw.Flush(totalLines)
}
func (s *pState) updateSyncMatrix() {