mirror of
https://github.com/containers/podman.git
synced 2025-11-30 18:18:18 +08:00
fix(deps): update module github.com/vbauerster/mpb/v8 to v8.7.3
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
113
vendor/github.com/vbauerster/mpb/v8/bar.go
generated
vendored
113
vendor/github.com/vbauerster/mpb/v8/bar.go
generated
vendored
@@ -44,12 +44,11 @@ type bState struct {
|
||||
rmOnComplete bool
|
||||
noPop bool
|
||||
autoRefresh bool
|
||||
aDecorators []decor.Decorator
|
||||
pDecorators []decor.Decorator
|
||||
buffers [3]*bytes.Buffer
|
||||
decorators [2][]decor.Decorator
|
||||
averageDecorators []decor.AverageDecorator
|
||||
ewmaDecorators []decor.EwmaDecorator
|
||||
shutdownListeners []decor.ShutdownListener
|
||||
buffers [3]*bytes.Buffer
|
||||
filler BarFiller
|
||||
extender extenderFunc
|
||||
renderReq chan<- time.Time
|
||||
@@ -159,10 +158,7 @@ func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
|
||||
iter := make(chan decor.Decorator)
|
||||
select {
|
||||
case b.operateState <- func(s *bState) {
|
||||
for _, decorators := range [][]decor.Decorator{
|
||||
s.pDecorators,
|
||||
s.aDecorators,
|
||||
} {
|
||||
for _, decorators := range s.decorators {
|
||||
for _, d := range decorators {
|
||||
iter <- d
|
||||
}
|
||||
@@ -250,9 +246,7 @@ func (b *Bar) EwmaSetCurrent(current int64, iterDur time.Duration) {
|
||||
}
|
||||
select {
|
||||
case b.operateState <- func(s *bState) {
|
||||
if n := current - s.current; n > 0 {
|
||||
s.decoratorEwmaUpdate(n, iterDur)
|
||||
}
|
||||
s.decoratorEwmaUpdate(current-s.current, iterDur)
|
||||
s.current = current
|
||||
if s.triggerComplete && s.current >= s.total {
|
||||
s.current = s.total
|
||||
@@ -411,22 +405,21 @@ func (b *Bar) serve(ctx context.Context, bs *bState) {
|
||||
|
||||
func (b *Bar) render(tw int) {
|
||||
fn := func(s *bState) {
|
||||
var rows []io.Reader
|
||||
frame := new(renderFrame)
|
||||
stat := newStatistics(tw, s)
|
||||
r, err := s.draw(stat)
|
||||
if err != nil {
|
||||
b.frameCh <- &renderFrame{err: err}
|
||||
for _, buf := range s.buffers {
|
||||
buf.Reset()
|
||||
}
|
||||
frame.err = err
|
||||
b.frameCh <- frame
|
||||
return
|
||||
}
|
||||
rows = append(rows, r)
|
||||
frame.rows = append(frame.rows, r)
|
||||
if s.extender != nil {
|
||||
rows, err = s.extender(rows, stat)
|
||||
if err != nil {
|
||||
b.frameCh <- &renderFrame{err: err}
|
||||
return
|
||||
}
|
||||
frame.rows, frame.err = s.extender(frame.rows, stat)
|
||||
}
|
||||
frame := &renderFrame{rows: rows}
|
||||
if s.completed || s.aborted {
|
||||
frame.shutdown = s.shutdown
|
||||
frame.rmOnComplete = s.rmOnComplete
|
||||
@@ -484,18 +477,7 @@ func (b *Bar) wSyncTable() syncTable {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *bState) draw(stat decor.Statistics) (io.Reader, error) {
|
||||
r, err := s.drawImpl(stat)
|
||||
if err != nil {
|
||||
for _, b := range s.buffers {
|
||||
b.Reset()
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return io.MultiReader(r, strings.NewReader("\n")), nil
|
||||
}
|
||||
|
||||
func (s *bState) drawImpl(stat decor.Statistics) (io.Reader, error) {
|
||||
func (s *bState) draw(stat decor.Statistics) (_ io.Reader, err error) {
|
||||
decorFiller := func(buf *bytes.Buffer, decorators []decor.Decorator) (err error) {
|
||||
for _, d := range decorators {
|
||||
// need to call Decor in any case becase of width synchronization
|
||||
@@ -515,45 +497,45 @@ func (s *bState) drawImpl(stat decor.Statistics) (io.Reader, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
bufP, bufB, bufA := s.buffers[0], s.buffers[1], s.buffers[2]
|
||||
|
||||
err := eitherError(decorFiller(bufP, s.pDecorators), decorFiller(bufA, s.aDecorators))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !s.trimSpace && stat.AvailableWidth >= 2 {
|
||||
stat.AvailableWidth -= 2
|
||||
writeFiller := func(buf *bytes.Buffer) error {
|
||||
return s.filler.Fill(buf, stat)
|
||||
}
|
||||
for _, fn := range []func(*bytes.Buffer) error{
|
||||
writeSpace,
|
||||
writeFiller,
|
||||
writeSpace,
|
||||
} {
|
||||
if err := fn(bufB); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err := s.filler.Fill(bufB, stat)
|
||||
for i, buf := range s.buffers[:2] {
|
||||
err = decorFiller(buf, s.decorators[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return io.MultiReader(bufP, bufB, bufA), nil
|
||||
spaces := []io.Reader{
|
||||
strings.NewReader(" "),
|
||||
strings.NewReader(" "),
|
||||
}
|
||||
if s.trimSpace || stat.AvailableWidth < 2 {
|
||||
for _, r := range spaces {
|
||||
_, _ = io.Copy(io.Discard, r)
|
||||
}
|
||||
} else {
|
||||
stat.AvailableWidth -= 2
|
||||
}
|
||||
|
||||
err = s.filler.Fill(s.buffers[2], stat)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return io.MultiReader(
|
||||
s.buffers[0],
|
||||
spaces[0],
|
||||
s.buffers[2],
|
||||
spaces[1],
|
||||
s.buffers[1],
|
||||
strings.NewReader("\n"),
|
||||
), nil
|
||||
}
|
||||
|
||||
func (s *bState) wSyncTable() (table syncTable) {
|
||||
var count int
|
||||
var row []chan int
|
||||
|
||||
for i, decorators := range [][]decor.Decorator{
|
||||
s.pDecorators,
|
||||
s.aDecorators,
|
||||
} {
|
||||
for i, decorators := range s.decorators {
|
||||
for _, d := range decorators {
|
||||
if ch, ok := d.Sync(); ok {
|
||||
row = append(row, ch)
|
||||
@@ -640,16 +622,3 @@ func unwrap(d decor.Decorator) decor.Decorator {
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func writeSpace(buf *bytes.Buffer) error {
|
||||
return buf.WriteByte(' ')
|
||||
}
|
||||
|
||||
func eitherError(errors ...error) error {
|
||||
for _, err := range errors {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user