From e85d630748b1d439ebec92f0d26311ca787e7655 Mon Sep 17 00:00:00 2001 From: Adam Jensen Date: Thu, 11 Mar 2021 12:17:47 -0500 Subject: [PATCH] s3store: Fix data loss when using deferred upload lengths (#462) --- pkg/s3store/s3store.go | 2 +- pkg/s3store/s3store_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/s3store/s3store.go b/pkg/s3store/s3store.go index 2411e42..3a37104 100644 --- a/pkg/s3store/s3store.go +++ b/pkg/s3store/s3store.go @@ -895,7 +895,7 @@ func (upload *s3Upload) concatUsingMultipart(ctx context.Context, partialUploads return upload.FinishUpload(ctx) } -func (upload s3Upload) DeclareLength(ctx context.Context, length int64) error { +func (upload *s3Upload) DeclareLength(ctx context.Context, length int64) error { info, err := upload.GetInfo(ctx) if err != nil { return err diff --git a/pkg/s3store/s3store_test.go b/pkg/s3store/s3store_test.go index 002923d..1c866d5 100644 --- a/pkg/s3store/s3store_test.go +++ b/pkg/s3store/s3store_test.go @@ -605,6 +605,9 @@ func TestDeclareLength(t *testing.T) { err = store.AsLengthDeclarableUpload(upload).DeclareLength(context.Background(), 500) assert.Nil(err) + info, err := upload.GetInfo(context.Background()) + assert.Nil(err) + assert.Equal(int64(500), info.Size) } func TestFinishUpload(t *testing.T) {