mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
progress bar: don't strings.Repeat a negative number
Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)
This commit is contained in:
parent
da40d9b7a5
commit
77237be0e2
1 changed files with 6 additions and 1 deletions
|
@ -50,7 +50,12 @@ func (p *JSONProgress) String() string {
|
|||
total := units.HumanSize(int64(p.Total))
|
||||
percentage := int(float64(p.Current)/float64(p.Total)*100) / 2
|
||||
if width > 110 {
|
||||
pbBox = fmt.Sprintf("[%s>%s] ", strings.Repeat("=", percentage), strings.Repeat(" ", 50-percentage))
|
||||
// this number can't be negetive gh#7136
|
||||
numSpaces := 0
|
||||
if 50-percentage > 0 {
|
||||
numSpaces = 50 - percentage
|
||||
}
|
||||
pbBox = fmt.Sprintf("[%s>%s] ", strings.Repeat("=", percentage), strings.Repeat(" ", numSpaces))
|
||||
}
|
||||
numbersBox = fmt.Sprintf("%8v/%v", current, total)
|
||||
|
||||
|
|
Loading…
Reference in a new issue