mirror of
https://github.com/containers/image.git
synced 2025-04-18 19:44:05 +03:00
copy: Don't print "skipped: 0.0b = 0.00%"
I think this is just visually noisy. If we didn't do a partial fetch then let's just not say anything about it. Signed-off-by: Colin Walters <walters@verbum.org>
This commit is contained in:
parent
3df133e402
commit
b18499a3c1
@ -24,13 +24,18 @@ func (c *copier) newProgressPool() *mpb.Progress {
|
||||
|
||||
// customPartialBlobDecorFunc implements mpb.DecorFunc for the partial blobs retrieval progress bar
|
||||
func customPartialBlobDecorFunc(s decor.Statistics) string {
|
||||
current := decor.SizeB1024(s.Current)
|
||||
total := decor.SizeB1024(s.Total)
|
||||
refill := decor.SizeB1024(s.Refill)
|
||||
if s.Total == 0 {
|
||||
pairFmt := "%.1f / %.1f (skipped: %.1f)"
|
||||
return fmt.Sprintf(pairFmt, decor.SizeB1024(s.Current), decor.SizeB1024(s.Total), decor.SizeB1024(s.Refill))
|
||||
return fmt.Sprintf("%.1f / %.1f (skipped: %.1f)", current, total, refill)
|
||||
}
|
||||
// If we didn't do a partial fetch then let's not output a distracting ("skipped: 0.0b = 0.00%")
|
||||
if s.Refill == 0 {
|
||||
return fmt.Sprintf("%.1f / %.1f", current, total)
|
||||
}
|
||||
pairFmt := "%.1f / %.1f (skipped: %.1f = %.2f%%)"
|
||||
percentage := 100.0 * float64(s.Refill) / float64(s.Total)
|
||||
return fmt.Sprintf(pairFmt, decor.SizeB1024(s.Current), decor.SizeB1024(s.Total), decor.SizeB1024(s.Refill), percentage)
|
||||
return fmt.Sprintf("%.1f / %.1f (skipped: %.1f = %.2f%%)", current, total, refill, percentage)
|
||||
}
|
||||
|
||||
// progressBar wraps a *mpb.Bar, allowing us to add extra state and methods.
|
||||
|
@ -20,5 +20,5 @@ func TestCustomPartialBlobDecorFunc(t *testing.T) {
|
||||
// Almost complete, but no reuse
|
||||
s.Current = int64(float64(s.Total) * 0.95)
|
||||
s.Refill = 0
|
||||
assert.Equal(t, "7.5MiB / 7.9MiB (skipped: 0.0b = 0.00%)", customPartialBlobDecorFunc(s))
|
||||
assert.Equal(t, "7.5MiB / 7.9MiB", customPartialBlobDecorFunc(s))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user