Skip to content

Commit 642d9ba

Browse files
authored
fix: return the entire blob size in patch upload response (#3279)
regclient/regclient#961 opencontainers/distribution-spec#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 <[email protected]>
1 parent b2a5afc commit 642d9ba

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pkg/storage/imagestore/imagestore.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,9 @@ func (is *ImageStore) PutBlobChunk(repo, uuid string, from, to int64,
943943

944944
defer file.Close()
945945

946-
if from != file.Size() {
946+
fsize := file.Size()
947+
948+
if from != fsize {
947949
is.log.Error().Int64("expected", from).Int64("actual", file.Size()).
948950
Msg("invalid range start for blob upload")
949951

@@ -952,7 +954,7 @@ func (is *ImageStore) PutBlobChunk(repo, uuid string, from, to int64,
952954

953955
n, err := io.Copy(file, body)
954956

955-
return n, err
957+
return n + fsize, err
956958
}
957959

958960
// BlobUploadInfo returns the current blob size in bytes.

pkg/storage/storage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ func TestStorageAPIs(t *testing.T) {
493493

494494
bupload, err = imgStore.PutBlobChunk("test", upload, int64(firstChunkLen), int64(buflen), secondChunkBuf)
495495
So(err, ShouldBeNil)
496-
So(bupload, ShouldEqual, secondChunkLen)
496+
So(bupload, ShouldEqual, int64(firstChunkLen+secondChunkLen))
497497

498498
err = imgStore.FinishBlobUpload("test", upload, buf, digest)
499499
So(err, ShouldBeNil)

0 commit comments

Comments
 (0)