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 <rchincha.dev@gmail.com>
This commit is contained in:
Ramkumar Chinchani
2025-07-30 17:32:54 -07:00
committed by GitHub
parent b2a5afc5c8
commit 642d9ba5cb
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -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.
+1 -1
View File
@@ -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)