Skip to content

Commit d4c1987

Browse files
ndeloofglours
authored andcommitted
Prevented incorrect progress metrics to break compose display.
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 1297f97 commit d4c1987

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

cmd/display/tty.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,12 @@ func (w *ttyWriter) lineText(t *task, pad string, terminalWidth, statusPadding i
347347
}
348348
total += child.total
349349
current += child.current
350-
completion = append(completion, percentChars[(len(percentChars)-1)*child.percent/100])
350+
r := len(percentChars) - 1
351+
p := child.percent
352+
if p > 100 {
353+
p = 100
354+
}
355+
completion = append(completion, percentChars[r*p/100])
351356
}
352357
}
353358

pkg/compose/pull.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ func toPullProgressEvent(parent string, jm jsonmessage.JSONMessage, events api.E
416416
total = jm.Progress.Total
417417
if jm.Progress.Total > 0 {
418418
percent = int(jm.Progress.Current * 100 / jm.Progress.Total)
419+
if percent > 100 {
420+
percent = 100
421+
}
419422
}
420423
}
421424
case DownloadCompletePhase, AlreadyExistsPhase, PullCompletePhase:

pkg/compose/push.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ func toPushProgressEvent(prefix string, jm jsonmessage.JSONMessage, events api.E
155155
total = jm.Progress.Total
156156
if jm.Progress.Total > 0 {
157157
percent = int(jm.Progress.Current * 100 / jm.Progress.Total)
158+
if percent > 100 {
159+
percent = 100
160+
}
158161
}
159162
}
160163
}

0 commit comments

Comments
 (0)