diff --git a/go.mod b/go.mod index 3aa349e7452..7266d9123f7 100644 --- a/go.mod +++ b/go.mod @@ -65,7 +65,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.10.1 + github.com/vbauerster/mpb/v8 v8.10.2 github.com/vishvananda/netlink v1.3.1 go.etcd.io/bbolt v1.4.0 golang.org/x/crypto v0.38.0 diff --git a/go.sum b/go.sum index 641a3bd5f0f..3d27d8aba69 100644 --- a/go.sum +++ b/go.sum @@ -477,8 +477,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.10.1 h1:t/ZFv/NYgoBUy2LrmkD5Vc25r+JhoS4+gRkjVbolO2Y= -github.com/vbauerster/mpb/v8 v8.10.1/go.mod h1:+Ja4P92E3/CorSZgfDtK46D7AVbDqmBQRTmyTqPElo0= +github.com/vbauerster/mpb/v8 v8.10.2 h1:2uBykSHAYHekE11YvJhKxYmLATKHAGorZwFlyNw4hHM= +github.com/vbauerster/mpb/v8 v8.10.2/go.mod h1:+Ja4P92E3/CorSZgfDtK46D7AVbDqmBQRTmyTqPElo0= github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW6bV0= github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4= github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY= diff --git a/vendor/github.com/vbauerster/mpb/v8/bar.go b/vendor/github.com/vbauerster/mpb/v8/bar.go index 5eb1123d234..db4f99c2929 100644 --- a/vendor/github.com/vbauerster/mpb/v8/bar.go +++ b/vendor/github.com/vbauerster/mpb/v8/bar.go @@ -145,13 +145,7 @@ func (b *Bar) Current() int64 { // operation for example. func (b *Bar) SetRefill(amount int64) { select { - case b.operateState <- func(s *bState) { - if amount < s.current { - s.refill = amount - } else { - s.refill = s.current - } - }: + case b.operateState <- func(s *bState) { s.refill = min(amount, s.current) }: case <-b.ctx.Done(): } } @@ -275,10 +269,10 @@ func (b *Bar) EwmaIncrInt64(n int64, iterDur time.Duration) { var wg sync.WaitGroup wg.Add(len(s.ewmaDecorators)) for _, d := range s.ewmaDecorators { - d := d + // d := d // NOTE: uncomment for Go < 1.22, see /doc/faq#closures_and_goroutines go func() { + defer wg.Done() d.EwmaUpdate(n, iterDur) - wg.Done() }() } s.current += n @@ -304,10 +298,10 @@ func (b *Bar) EwmaSetCurrent(current int64, iterDur time.Duration) { var wg sync.WaitGroup wg.Add(len(s.ewmaDecorators)) for _, d := range s.ewmaDecorators { - d := d + // d := d // NOTE: uncomment for Go < 1.22, see /doc/faq#closures_and_goroutines go func() { + defer wg.Done() d.EwmaUpdate(n, iterDur) - wg.Done() }() } s.current = current @@ -394,13 +388,14 @@ func (b *Bar) Wait() { } func (b *Bar) serve(bs *bState) { + defer b.container.bwg.Done() decoratorsOnShutdown := func(group []decor.Decorator) { for _, d := range group { if d, ok := unwrap(d).(decor.ShutdownListener); ok { b.container.bwg.Add(1) go func() { + defer b.container.bwg.Done() d.OnShutdown() - b.container.bwg.Done() }() } } @@ -416,7 +411,6 @@ func (b *Bar) serve(bs *bState) { bs.aborted = !bs.completed() b.bs = bs close(b.bsOk) - b.container.bwg.Done() return } } diff --git a/vendor/github.com/vbauerster/mpb/v8/bar_filler_bar.go b/vendor/github.com/vbauerster/mpb/v8/bar_filler_bar.go index bc51eb26f23..4dca113d08e 100644 --- a/vendor/github.com/vbauerster/mpb/v8/bar_filler_bar.go +++ b/vendor/github.com/vbauerster/mpb/v8/bar_filler_bar.go @@ -175,12 +175,12 @@ func (s barStyle) Build() BarFiller { bytes: []byte(s.style[iPadding]), } bf.tip.onComplete = s.tipOnComplete - bf.tip.frames = make([]component, len(s.tipFrames)) - for i, t := range s.tipFrames { - bf.tip.frames[i] = component{ + bf.tip.frames = make([]component, 0, len(s.tipFrames)) + for _, t := range s.tipFrames { + bf.tip.frames = append(bf.tip.frames, component{ width: runewidth.StringWidth(t), bytes: []byte(t), - } + }) } if s.rev { bf.flushOp = barSections.flushRev diff --git a/vendor/github.com/vbauerster/mpb/v8/priority_queue.go b/vendor/github.com/vbauerster/mpb/v8/priority_queue.go index a93b1e59047..c2f657db0a4 100644 --- a/vendor/github.com/vbauerster/mpb/v8/priority_queue.go +++ b/vendor/github.com/vbauerster/mpb/v8/priority_queue.go @@ -21,17 +21,17 @@ func (pq priorityQueue) Swap(i, j int) { func (pq *priorityQueue) Push(x interface{}) { s := *pq - bar := x.(*Bar) - bar.index = len(s) - *pq = append(s, bar) + b := x.(*Bar) + b.index = len(s) + *pq = append(s, b) } func (pq *priorityQueue) Pop() interface{} { + var b *Bar s := *pq - l := len(s) - bar := s[l-1] - bar.index = -1 // for safety - s[l-1] = nil // avoid memory leak - *pq = s[:l-1] - return bar + i := len(s) - 1 + b, s[i] = s[i], nil // nil to avoid memory leak + b.index = -1 // for safety + *pq = s[:i] + return b } diff --git a/vendor/github.com/vbauerster/mpb/v8/progress.go b/vendor/github.com/vbauerster/mpb/v8/progress.go index ee4f722953e..851083c4072 100644 --- a/vendor/github.com/vbauerster/mpb/v8/progress.go +++ b/vendor/github.com/vbauerster/mpb/v8/progress.go @@ -355,16 +355,18 @@ func (s *pState) render(cw *cwriter.Writer) (err error) { height = width } + var barCount int for b := range iter { + barCount++ go b.render(width) } - return s.flush(cw, height, iterPop) + return s.flush(cw, height, barCount, iterPop) } -func (s *pState) flush(cw *cwriter.Writer, height int, iter <-chan *Bar) error { - var popCount int - var rows []io.Reader +func (s *pState) flush(cw *cwriter.Writer, height, barCount int, iter <-chan *Bar) error { + var total, popCount int + rows := make([][]io.Reader, 0, barCount) for b := range iter { frame := <-b.frameCh @@ -373,15 +375,16 @@ func (s *pState) flush(cw *cwriter.Writer, height int, iter <-chan *Bar) error { b.cancel() return frame.err // b.frameCh is buffered it's ok to return here } - var usedRows int + var discarded int for i := len(frame.rows) - 1; i >= 0; i-- { - if row := frame.rows[i]; len(rows) < height { - rows = append(rows, row) - usedRows++ + if total < height { + total++ } else { - _, _ = io.Copy(io.Discard, row) + _, _ = io.Copy(io.Discard, frame.rows[i]) // Found IsInBounds + discarded++ } } + rows = append(rows, frame.rows) switch frame.shutdown { case 1: @@ -399,7 +402,7 @@ func (s *pState) flush(cw *cwriter.Writer, height int, iter <-chan *Bar) error { } case 2: if s.popCompleted && !frame.noPop { - popCount += usedRows + popCount += len(frame.rows) - discarded continue } fallthrough @@ -409,13 +412,15 @@ func (s *pState) flush(cw *cwriter.Writer, height int, iter <-chan *Bar) error { } for i := len(rows) - 1; i >= 0; i-- { - _, err := cw.ReadFrom(rows[i]) - if err != nil { - return err + for _, r := range rows[i] { + _, err := cw.ReadFrom(r) + if err != nil { + return err + } } } - return cw.Flush(len(rows) - popCount) + return cw.Flush(total - popCount) } func (s pState) makeBarState(total int64, filler BarFiller, options ...BarOption) *bState { diff --git a/vendor/modules.txt b/vendor/modules.txt index f99c47d571d..c85699dc0c5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -987,7 +987,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.10.1 +# github.com/vbauerster/mpb/v8 v8.10.2 ## explicit; go 1.23.0 github.com/vbauerster/mpb/v8 github.com/vbauerster/mpb/v8/cwriter