Skip to content

Commit

Permalink
Merge pull request #5 from SiaFoundation/chris/multipart-complete-meta
Browse files Browse the repository at this point in the history
Extend CompleteMultipartUpload with metadata
  • Loading branch information
ChrisSchinnerl authored Mar 14, 2024
2 parents e0d47c1 + c206381 commit ffb9814
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ type MultipartBackend interface {
ListParts(ctx context.Context, bucket, object string, uploadID UploadID, marker int, limit int64) (*ListMultipartUploadPartsResult, error)

AbortMultipartUpload(ctx context.Context, bucket, object string, id UploadID) error
CompleteMultipartUpload(ctx context.Context, bucket, object string, id UploadID, input *CompleteMultipartUploadRequest) (*CompleteMultipartUploadResult, error)
CompleteMultipartUpload(ctx context.Context, bucket, object string, id UploadID, meta map[string]string, input *CompleteMultipartUploadRequest) (*CompleteMultipartUploadResult, error)
}

type AuthenticatedBackend interface {
Expand Down
7 changes: 6 additions & 1 deletion gofakes3.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,12 @@ func (g *GoFakeS3) completeMultipartUpload(bucket, object string, uploadID Uploa
return err
}

res, err := g.uploader.CompleteMultipartUpload(r.Context(), bucket, object, uploadID, &in)
meta, err := metadataHeaders(r.Header, g.timeSource.Now(), g.metadataSizeLimit)
if err != nil {
return err
}

res, err := g.uploader.CompleteMultipartUpload(r.Context(), bucket, object, uploadID, meta, &in)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,16 @@ func (u *uploader) UploadPart(_ context.Context, bucket, object string, id Uploa
return &UploadPartResult{ETag: etag}, nil
}

func (u *uploader) CompleteMultipartUpload(ctx context.Context, bucket, object string, id UploadID, input *CompleteMultipartUploadRequest) (*CompleteMultipartUploadResult, error) {
func (u *uploader) CompleteMultipartUpload(ctx context.Context, bucket, object string, id UploadID, meta map[string]string, input *CompleteMultipartUploadRequest) (*CompleteMultipartUploadResult, error) {
mpu, err := u.getUnlocked(bucket, object, id)
if err != nil {
return nil, err
}

for k, v := range meta {
mpu.Meta[k] = v
}

mpu.mu.Lock()
defer mpu.mu.Unlock()

Expand Down

0 comments on commit ffb9814

Please sign in to comment.