diff --git a/go.mod b/go.mod index 305d41128f..5513147baa 100644 --- a/go.mod +++ b/go.mod @@ -68,7 +68,7 @@ require ( github.com/spf13/cobra v1.9.1 github.com/spf13/pflag v1.0.6 github.com/stretchr/testify v1.10.0 - github.com/vbauerster/mpb/v8 v8.9.2 + github.com/vbauerster/mpb/v8 v8.9.3 github.com/vishvananda/netlink v1.3.1-0.20250128002108-7c2350bd140f go.etcd.io/bbolt v1.3.11 golang.org/x/crypto v0.33.0 diff --git a/go.sum b/go.sum index d90f8ac5d3..52f46359df 100644 --- a/go.sum +++ b/go.sum @@ -515,8 +515,8 @@ github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc= github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/vbatts/tar-split v0.12.1 h1:CqKoORW7BUWBe7UL/iqTVvkTBOF8UvOMKOIZykxnnbo= github.com/vbatts/tar-split v0.12.1/go.mod h1:eF6B6i6ftWQcDqEn3/iGFRFRo8cBIMSJVOpnNdfTMFA= -github.com/vbauerster/mpb/v8 v8.9.2 h1:kb91+D643Qg040bbICYtzpjgZ9ypVO/+sjv4Jcm6si4= -github.com/vbauerster/mpb/v8 v8.9.2/go.mod h1:hxS8Hz4C6ijnppDSIX6LjG8FYJSoPo9iIOcE53Zik0c= +github.com/vbauerster/mpb/v8 v8.9.3 h1:PnMeF+sMvYv9u23l6DO6Q3+Mdj408mjLRXIzmUmU2Z8= +github.com/vbauerster/mpb/v8 v8.9.3/go.mod h1:hxS8Hz4C6ijnppDSIX6LjG8FYJSoPo9iIOcE53Zik0c= github.com/vishvananda/netlink v1.3.1-0.20250128002108-7c2350bd140f h1:G5t3qYQ3YL2zMn2kFzRYIPk1EvDvMNV9pP+w+39VtzI= github.com/vishvananda/netlink v1.3.1-0.20250128002108-7c2350bd140f/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= diff --git a/vendor/github.com/vbauerster/mpb/v8/bar.go b/vendor/github.com/vbauerster/mpb/v8/bar.go index a76f51d455..5eb1123d23 100644 --- a/vendor/github.com/vbauerster/mpb/v8/bar.go +++ b/vendor/github.com/vbauerster/mpb/v8/bar.go @@ -45,7 +45,7 @@ type bState struct { noPop bool autoRefresh bool buffers [3]*bytes.Buffer - decorators [2][]decor.Decorator + decorGroups [2][]decor.Decorator ewmaDecorators []decor.EwmaDecorator filler BarFiller extender extenderFunc @@ -156,24 +156,16 @@ func (b *Bar) SetRefill(amount int64) { } } -// TraverseDecorators traverses available decorators and calls cb func -// on each in a new goroutine. Decorators implementing decor.Wrapper -// interface are unwrapped first. +// TraverseDecorators traverses available decorators and calls `cb` +// on each unwrapped one. func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) { select { case b.operateState <- func(s *bState) { - var wg sync.WaitGroup - for _, decorators := range s.decorators { - wg.Add(len(decorators)) - for _, d := range decorators { - d := d - go func() { - cb(unwrap(d)) - wg.Done() - }() + for _, group := range s.decorGroups { + for _, d := range group { + cb(unwrap(d)) } } - wg.Wait() }: case <-b.ctx.Done(): } @@ -402,8 +394,8 @@ func (b *Bar) Wait() { } func (b *Bar) serve(bs *bState) { - decoratorsOnShutdown := func(decorators []decor.Decorator) { - for _, d := range decorators { + decoratorsOnShutdown := func(group []decor.Decorator) { + for _, d := range group { if d, ok := unwrap(d).(decor.ShutdownListener); ok { b.container.bwg.Add(1) go func() { @@ -418,8 +410,8 @@ func (b *Bar) serve(bs *bState) { case op := <-b.operateState: op(bs) case <-b.ctx.Done(): - decoratorsOnShutdown(bs.decorators[0]) - decoratorsOnShutdown(bs.decorators[1]) + decoratorsOnShutdown(bs.decorGroups[0]) + decoratorsOnShutdown(bs.decorGroups[1]) // bar can be aborted by canceling parent ctx without calling b.Abort bs.aborted = !bs.completed() b.bs = bs @@ -491,8 +483,8 @@ func (b *Bar) wSyncTable() syncTable { } 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 { + decorFiller := func(buf *bytes.Buffer, group []decor.Decorator) (err error) { + for _, d := range group { // need to call Decor in any case because of width synchronization str, width := d.Decor(stat) if err != nil { @@ -511,7 +503,7 @@ func (s *bState) draw(stat decor.Statistics) (_ io.Reader, err error) { } for i, buf := range s.buffers[:2] { - err = decorFiller(buf, s.decorators[i]) + err = decorFiller(buf, s.decorGroups[i]) if err != nil { return nil, err } @@ -545,34 +537,20 @@ func (s *bState) draw(stat decor.Statistics) (_ io.Reader, err error) { } func (s *bState) wSyncTable() (table syncTable) { - var count int + var start int var row []chan int - for i, decorators := range s.decorators { - for _, d := range decorators { + for i, group := range s.decorGroups { + for _, d := range group { if ch, ok := d.Sync(); ok { row = append(row, ch) - count++ } } - switch i { - case 0: - table[i] = row[0:count] - default: - table[i] = row[len(table[i-1]):count] - } + table[i], start = row[start:], len(row) } return table } -func (s *bState) populateEwmaDecorators(decorators []decor.Decorator) { - for _, d := range decorators { - if d, ok := unwrap(d).(decor.EwmaDecorator); ok { - s.ewmaDecorators = append(s.ewmaDecorators, d) - } - } -} - func (s *bState) triggerCompletion(b *Bar) { s.triggerComplete = true if s.autoRefresh { diff --git a/vendor/github.com/vbauerster/mpb/v8/bar_option.go b/vendor/github.com/vbauerster/mpb/v8/bar_option.go index 6247a334cc..b586f69445 100644 --- a/vendor/github.com/vbauerster/mpb/v8/bar_option.go +++ b/vendor/github.com/vbauerster/mpb/v8/bar_option.go @@ -10,31 +10,29 @@ import ( // BarOption is a func option to alter default behavior of a bar. type BarOption func(*bState) -func inspect(decorators []decor.Decorator) (dest []decor.Decorator) { - for _, decorator := range decorators { - if decorator == nil { - continue - } - dest = append(dest, decorator) - } - return -} - // PrependDecorators let you inject decorators to the bar's left side. func PrependDecorators(decorators ...decor.Decorator) BarOption { - decorators = inspect(decorators) + var group []decor.Decorator + for _, decorator := range decorators { + if decorator != nil { + group = append(group, decorator) + } + } return func(s *bState) { - s.populateEwmaDecorators(decorators) - s.decorators[0] = decorators + s.decorGroups[0] = group } } // AppendDecorators let you inject decorators to the bar's right side. func AppendDecorators(decorators ...decor.Decorator) BarOption { - decorators = inspect(decorators) + var group []decor.Decorator + for _, decorator := range decorators { + if decorator != nil { + group = append(group, decorator) + } + } return func(s *bState) { - s.populateEwmaDecorators(decorators) - s.decorators[1] = decorators + s.decorGroups[1] = group } } diff --git a/vendor/github.com/vbauerster/mpb/v8/progress.go b/vendor/github.com/vbauerster/mpb/v8/progress.go index 8808ad745a..ee4f722953 100644 --- a/vendor/github.com/vbauerster/mpb/v8/progress.go +++ b/vendor/github.com/vbauerster/mpb/v8/progress.go @@ -442,6 +442,14 @@ func (s pState) makeBarState(total int64, filler BarFiller, options ...BarOption } } + for _, group := range bs.decorGroups { + for _, d := range group { + if d, ok := unwrap(d).(decor.EwmaDecorator); ok { + bs.ewmaDecorators = append(bs.ewmaDecorators, d) + } + } + } + bs.buffers[0] = bytes.NewBuffer(make([]byte, 0, 128)) // prepend bs.buffers[1] = bytes.NewBuffer(make([]byte, 0, 128)) // append bs.buffers[2] = bytes.NewBuffer(make([]byte, 0, 256)) // filler diff --git a/vendor/modules.txt b/vendor/modules.txt index ec2a5705af..b8e5ca2043 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1110,7 +1110,7 @@ github.com/ulikunitz/xz/lzma github.com/vbatts/tar-split/archive/tar github.com/vbatts/tar-split/tar/asm github.com/vbatts/tar-split/tar/storage -# github.com/vbauerster/mpb/v8 v8.9.2 +# github.com/vbauerster/mpb/v8 v8.9.3 ## explicit; go 1.17 github.com/vbauerster/mpb/v8 github.com/vbauerster/mpb/v8/cwriter