Update module github.com/vbauerster/mpb/v8 to v8.7.4

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
renovate[bot] 2024-07-20 15:19:17 +00:00 committed by GitHub
parent db6f7d5e82
commit 742d29e9d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 35 additions and 33 deletions

2
go.mod
View File

@ -67,7 +67,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.9.0
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/vbauerster/mpb/v8 v8.7.3
github.com/vbauerster/mpb/v8 v8.7.4
github.com/vishvananda/netlink v1.2.1-beta.2
go.etcd.io/bbolt v1.3.10
golang.org/x/crypto v0.25.0

4
go.sum
View File

@ -508,8 +508,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.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts=
github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk=
github.com/vbauerster/mpb/v8 v8.7.3 h1:n/mKPBav4FFWp5fH4U0lPpXfiOmCEgl5Yx/NM3tKJA0=
github.com/vbauerster/mpb/v8 v8.7.3/go.mod h1:9nFlNpDGVoTmQ4QvNjSLtwLmAFjwmq0XaAF26toHGNM=
github.com/vbauerster/mpb/v8 v8.7.4 h1:p4f16iMfUt3PkAC73SCzAtgtSf8TYDqEbJUT3odPrPo=
github.com/vbauerster/mpb/v8 v8.7.4/go.mod h1:r1B5k2Ljj5KJFCekfihbiqyV4VaaRTANYmvWA2btufI=
github.com/vishvananda/netlink v1.2.1-beta.2 h1:Llsql0lnQEbHj0I1OuKyp8otXp0r3q0mPkuhwHfStVs=
github.com/vishvananda/netlink v1.2.1-beta.2/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=

View File

@ -233,7 +233,7 @@ func (s *bFiller) Fill(w io.Writer, stat decor.Statistics) error {
var tip component
var refilling, filling, padding []byte
var fillCount int
curWidth := int(internal.PercentageRound(stat.Total, stat.Current, uint(width)))
curWidth := int(internal.PercentageRound(stat.Total, stat.Current, int64(width)))
if curWidth != 0 {
if !stat.Completed || s.tipOnComplete {
@ -241,20 +241,19 @@ func (s *bFiller) Fill(w io.Writer, stat decor.Statistics) error {
s.tip.count++
fillCount += tip.width
}
if stat.Refill != 0 {
refWidth := int(internal.PercentageRound(stat.Total, stat.Refill, uint(width)))
switch refWidth := 0; {
case stat.Refill != 0:
refWidth = int(internal.PercentageRound(stat.Total, stat.Refill, int64(width)))
curWidth -= refWidth
refWidth += curWidth
fallthrough
default:
for w := s.components[iFiller].width; curWidth-fillCount >= w; fillCount += w {
filling = append(filling, s.components[iFiller].bytes...)
}
for w := s.components[iRefiller].width; refWidth-fillCount >= w; fillCount += w {
refilling = append(refilling, s.components[iRefiller].bytes...)
}
} else {
for w := s.components[iFiller].width; curWidth-fillCount >= w; fillCount += w {
filling = append(filling, s.components[iFiller].bytes...)
}
}
}

View File

@ -81,15 +81,15 @@ func (d *movingAverageETA) Decor(s Statistics) (string, int) {
func (d *movingAverageETA) EwmaUpdate(n int64, dur time.Duration) {
if n <= 0 {
d.zDur += dur
} else {
durPerItem := float64(d.zDur+dur) / float64(n)
if math.IsInf(durPerItem, 0) || math.IsNaN(durPerItem) {
d.zDur += dur
return
}
d.zDur = 0
d.average.Add(durPerItem)
return
}
durPerItem := float64(d.zDur+dur) / float64(n)
if math.IsInf(durPerItem, 0) || math.IsNaN(durPerItem) {
d.zDur += dur
return
}
d.zDur = 0
d.average.Add(durPerItem)
}
// AverageETA decorator. It's wrapper of NewAverageETA.

View File

@ -61,7 +61,7 @@ func NewPercentage(format string, wcc ...WC) Decorator {
format = "% d"
}
f := func(s Statistics) string {
p := internal.Percentage(s.Total, s.Current, 100)
p := internal.PercentageRound(s.Total, s.Current, 100)
return fmt.Sprintf(format, percentageType(p))
}
return Any(f, wcc...)

View File

@ -96,15 +96,15 @@ func (d *movingAverageSpeed) Decor(_ Statistics) (string, int) {
func (d *movingAverageSpeed) EwmaUpdate(n int64, dur time.Duration) {
if n <= 0 {
d.zDur += dur
} else {
durPerByte := float64(d.zDur+dur) / float64(n)
if math.IsInf(durPerByte, 0) || math.IsNaN(durPerByte) {
d.zDur += dur
return
}
d.zDur = 0
d.average.Add(durPerByte)
return
}
durPerByte := float64(d.zDur+dur) / float64(n)
if math.IsInf(durPerByte, 0) || math.IsNaN(durPerByte) {
d.zDur += dur
return
}
d.zDur = 0
d.average.Add(durPerByte)
}
// AverageSpeed decorator with dynamic unit measure adjustment. It's

View File

@ -3,17 +3,20 @@ package internal
import "math"
// Percentage is a helper function, to calculate percentage.
func Percentage(total, current int64, width uint) float64 {
if total <= 0 {
func Percentage(total, current, width uint) float64 {
if total == 0 {
return 0
}
if current >= total {
return float64(width)
}
return float64(int64(width)*current) / float64(total)
return float64(width*current) / float64(total)
}
// PercentageRound same as Percentage but with math.Round.
func PercentageRound(total, current int64, width uint) float64 {
return math.Round(Percentage(total, current, width))
func PercentageRound(total, current, width int64) float64 {
if total < 0 || current < 0 || width < 0 {
return 0
}
return math.Round(Percentage(uint(total), uint(current), uint(width)))
}

2
vendor/modules.txt vendored
View File

@ -1079,7 +1079,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.7.3
# github.com/vbauerster/mpb/v8 v8.7.4
## explicit; go 1.17
github.com/vbauerster/mpb/v8
github.com/vbauerster/mpb/v8/cwriter