From 2837c2a3e3c79c7e3779267c77fa93a7876f6571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 27 Apr 2022 00:27:08 +0200 Subject: [PATCH] Don't call bar.SetRefill with negative numbers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If srcInfo.Size == -1, the progress bar is not showing the refill value anyway (customPartialBlobDecorFunc is only used if size is known), so don't bother calling this function with nonsense data, if anything, at least to emphasize that this condition is, in principle, possible. Should not affect behavior, hopefully. Signed-off-by: Miloslav Trmač --- copy/copy.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/copy/copy.go b/copy/copy.go index c6f31ad8b..74da68eb3 100644 --- a/copy/copy.go +++ b/copy/copy.go @@ -1210,7 +1210,9 @@ func (ic *imageCopier) copyLayer(ctx context.Context, srcInfo types.BlobInfo, to } info, err := ic.c.dest.PutBlobPartial(ctx, &proxy, srcInfo, ic.c.blobInfoCache) if err == nil { - bar.SetRefill(srcInfo.Size - bar.Current()) + if srcInfo.Size != -1 { + bar.SetRefill(srcInfo.Size - bar.Current()) + } bar.mark100PercentComplete() hideProgressBar = false logrus.Debugf("Retrieved partial blob %v", srcInfo.Digest)