From c1ea40ba74f114013a8d6b6ab2b740f8fe669d0c Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Mon, 15 Dec 2025 17:43:32 +0100 Subject: [PATCH] Prevented incorrect progress metrics to break compose display. Signed-off-by: Nicolas De Loof --- cmd/display/tty.go | 7 ++++++- pkg/compose/pull.go | 3 +++ pkg/compose/push.go | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/display/tty.go b/cmd/display/tty.go index b6ba14d9bd2..04469cfd71f 100644 --- a/cmd/display/tty.go +++ b/cmd/display/tty.go @@ -347,7 +347,12 @@ func (w *ttyWriter) lineText(t *task, pad string, terminalWidth, statusPadding i } total += child.total current += child.current - completion = append(completion, percentChars[(len(percentChars)-1)*child.percent/100]) + r := len(percentChars) - 1 + p := child.percent + if p > 100 { + p = 100 + } + completion = append(completion, percentChars[r*p/100]) } } diff --git a/pkg/compose/pull.go b/pkg/compose/pull.go index 276f2f6d706..e2845aad86e 100644 --- a/pkg/compose/pull.go +++ b/pkg/compose/pull.go @@ -416,6 +416,9 @@ func toPullProgressEvent(parent string, jm jsonmessage.JSONMessage, events api.E total = jm.Progress.Total if jm.Progress.Total > 0 { percent = int(jm.Progress.Current * 100 / jm.Progress.Total) + if percent > 100 { + percent = 100 + } } } case DownloadCompletePhase, AlreadyExistsPhase, PullCompletePhase: diff --git a/pkg/compose/push.go b/pkg/compose/push.go index abf9453530a..a1e9b2686e4 100644 --- a/pkg/compose/push.go +++ b/pkg/compose/push.go @@ -155,6 +155,9 @@ func toPushProgressEvent(prefix string, jm jsonmessage.JSONMessage, events api.E total = jm.Progress.Total if jm.Progress.Total > 0 { percent = int(jm.Progress.Current * 100 / jm.Progress.Total) + if percent > 100 { + percent = 100 + } } } }