Skip to content

Commit

Permalink
api: Store SplitID in multipart meta info
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
  • Loading branch information
smallhive committed Feb 22, 2024
1 parent d6d9a7d commit 302cc55
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/data/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type MultipartInfo struct {
Created time.Time
Meta map[string]string
CopiesNumber uint32
SplitID string
}

// PartInfo is upload information about part.
Expand Down
2 changes: 2 additions & 0 deletions api/layer/multipart_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/nspcc-dev/neofs-s3-gw/api/data"
"github.com/nspcc-dev/neofs-s3-gw/api/layer/encryption"
"github.com/nspcc-dev/neofs-s3-gw/api/s3errors"
"github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/user"
"go.uber.org/zap"
Expand Down Expand Up @@ -148,6 +149,7 @@ func (n *layer) CreateMultipartUpload(ctx context.Context, p *CreateMultipartPar
Created: TimeNow(ctx),
Meta: make(map[string]string, metaSize),
CopiesNumber: p.CopiesNumber,
SplitID: object.NewSplitID().String(),
}

for key, val := range p.Header {
Expand Down
4 changes: 4 additions & 0 deletions internal/neofs/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const (
isUnversionedKV = "IsUnversioned"
isTagKV = "IsTag"
uploadIDKV = "UploadId"
splitIDKV = "SplitId"
partNumberKV = "Number"
sizeKV = "Size"
etagKV = "ETag"
Expand Down Expand Up @@ -221,6 +222,8 @@ func newMultipartInfo(node NodeResponse) (*data.MultipartInfo, error) {
}
case ownerKV:
_ = multipartInfo.Owner.DecodeString(string(kv.GetValue()))
case splitIDKV:
multipartInfo.SplitID = string(kv.GetValue())
default:
multipartInfo.Meta[kv.GetKey()] = string(kv.GetValue())
}
Expand Down Expand Up @@ -1191,6 +1194,7 @@ func metaFromMultipart(info *data.MultipartInfo, fileName string) map[string]str
info.Meta[uploadIDKV] = info.UploadID
info.Meta[ownerKV] = info.Owner.EncodeToString()
info.Meta[createdKV] = strconv.FormatInt(info.Created.UTC().UnixMilli(), 10)
info.Meta[splitIDKV] = info.SplitID

return info.Meta
}
Expand Down

0 comments on commit 302cc55

Please sign in to comment.