From 3f1ebde4264e215522ca539c777ea7e719e60075 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Wed, 17 Apr 2024 14:34:07 +0300 Subject: [PATCH] [#370] Fix multipart upload size in tree node Signed-off-by: Denis Kirillov --- api/handler/multipart_upload_test.go | 16 ++++++++++++++++ api/layer/object.go | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/api/handler/multipart_upload_test.go b/api/handler/multipart_upload_test.go index 003cf065..5b004c0b 100644 --- a/api/handler/multipart_upload_test.go +++ b/api/handler/multipart_upload_test.go @@ -92,6 +92,22 @@ func TestDeleteMultipartAllParts(t *testing.T) { require.Empty(t, hc.tp.Objects()) } +func TestMultipartTreeSize(t *testing.T) { + hc := prepareHandlerContext(t) + + partSize := layer.UploadMinSize + objLen := 6 * partSize + + bktName, objName := "bucket", "object" + + bktInfo := createTestBucket(hc, bktName) + multipartUpload(hc, bktName, objName, nil, objLen, partSize) + + nodeVersion, err := hc.tree.GetLatestVersion(hc.Context(), bktInfo, objName) + require.NoError(t, err) + require.EqualValues(t, objLen, nodeVersion.Size) +} + func TestMultipartUploadInvalidPart(t *testing.T) { hc := prepareHandlerContext(t) diff --git a/api/layer/object.go b/api/layer/object.go index 5c24d1ca..c1b0d15b 100644 --- a/api/layer/object.go +++ b/api/layer/object.go @@ -315,7 +315,7 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Extend OID: id, ETag: hex.EncodeToString(hash), FilePath: p.Object, - Size: size, + Size: p.Size, }, IsUnversioned: !bktSettings.VersioningEnabled(), IsCombined: p.Header[MultipartObjectSize] != "", @@ -356,7 +356,7 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Extend Owner: n.gateOwner, Bucket: p.BktInfo.Name, Name: p.Object, - Size: size, + Size: size, // we don't use here p.Size to be consistent with the objectInfoFromMeta function Created: prm.CreationTime, Headers: p.Header, ContentType: p.Header[api.ContentType],