mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
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:
committed by
GitHub
parent
b2a5afc5c8
commit
642d9ba5cb
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user