From 642d9ba5cbb5a62fafd76cf9a6ec007b8cb0691a Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani <45800463+rchincha@users.noreply.github.com> Date: Wed, 30 Jul 2025 17:32:54 -0700 Subject: [PATCH] fix: return the entire blob size in patch upload response (#3279) https://github.com/regclient/regclient/issues/961 https://github.com/opencontainers/distribution-spec/pull/581 Previously, zot returned the size of the currently uploaded chunk. Other registries the size of the entire blob. Align with the latter behavior. Signed-off-by: Ramkumar Chinchani --- pkg/storage/imagestore/imagestore.go | 6 ++++-- pkg/storage/storage_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/storage/imagestore/imagestore.go b/pkg/storage/imagestore/imagestore.go index 4ae27ae4..790e31a3 100644 --- a/pkg/storage/imagestore/imagestore.go +++ b/pkg/storage/imagestore/imagestore.go @@ -943,7 +943,9 @@ func (is *ImageStore) PutBlobChunk(repo, uuid string, from, to int64, defer file.Close() - if from != file.Size() { + fsize := file.Size() + + if from != fsize { is.log.Error().Int64("expected", from).Int64("actual", file.Size()). Msg("invalid range start for blob upload") @@ -952,7 +954,7 @@ func (is *ImageStore) PutBlobChunk(repo, uuid string, from, to int64, n, err := io.Copy(file, body) - return n, err + return n + fsize, err } // BlobUploadInfo returns the current blob size in bytes. diff --git a/pkg/storage/storage_test.go b/pkg/storage/storage_test.go index caff8017..12eca9a6 100644 --- a/pkg/storage/storage_test.go +++ b/pkg/storage/storage_test.go @@ -493,7 +493,7 @@ func TestStorageAPIs(t *testing.T) { bupload, err = imgStore.PutBlobChunk("test", upload, int64(firstChunkLen), int64(buflen), secondChunkBuf) So(err, ShouldBeNil) - So(bupload, ShouldEqual, secondChunkLen) + So(bupload, ShouldEqual, int64(firstChunkLen+secondChunkLen)) err = imgStore.FinishBlobUpload("test", upload, buf, digest) So(err, ShouldBeNil)