diff --git a/jsonmessage/jsonmessage.go b/jsonmessage/jsonmessage.go index f3bcc8e..f12547c 100644 --- a/jsonmessage/jsonmessage.go +++ b/jsonmessage/jsonmessage.go @@ -67,8 +67,14 @@ func (p *JSONProgress) String() string { } pbBox = fmt.Sprintf("[%s>%s] ", strings.Repeat("=", percentage), strings.Repeat(" ", numSpaces)) } + numbersBox = fmt.Sprintf("%8v/%v", current, total) + if p.Current > p.Total { + // remove total display if the reported current is wonky. + numbersBox = fmt.Sprintf("%8v", current) + } + if p.Current > 0 && p.Start > 0 && percentage < 50 { fromStart := time.Now().UTC().Sub(time.Unix(p.Start, 0)) perEntry := fromStart / time.Duration(p.Current) diff --git a/jsonmessage/jsonmessage_test.go b/jsonmessage/jsonmessage_test.go index 2e78fa7..889b0ba 100644 --- a/jsonmessage/jsonmessage_test.go +++ b/jsonmessage/jsonmessage_test.go @@ -3,12 +3,12 @@ package jsonmessage import ( "bytes" "fmt" + "strings" "testing" "time" "github.com/docker/docker/pkg/term" "github.com/docker/docker/pkg/timeutils" - "strings" ) func TestError(t *testing.T) { @@ -45,7 +45,7 @@ func TestProgress(t *testing.T) { } // this number can't be negative gh#7136 - expected = "[==================================================>] 50 B/40 B" + expected = "[==================================================>] 50 B" jp5 := JSONProgress{Current: 50, Total: 40} if jp5.String() != expected { t.Fatalf("Expected %q, got %q", expected, jp5.String())