forked from TrueCloudLab/frostfs-s3-gw
[#478] Don't fetch epoch at object upload
Creation epoch was used for versioning. With tree service, versioning is done on the NeoFS side in the tree. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
9dfc7e043f
commit
4f3d206422
3 changed files with 24 additions and 36 deletions
|
@ -33,15 +33,14 @@ type (
|
||||||
IsDir bool
|
IsDir bool
|
||||||
IsDeleteMarker bool
|
IsDeleteMarker bool
|
||||||
|
|
||||||
Bucket string
|
Bucket string
|
||||||
Name string
|
Name string
|
||||||
Size int64
|
Size int64
|
||||||
ContentType string
|
ContentType string
|
||||||
Created time.Time
|
Created time.Time
|
||||||
CreationEpoch uint64
|
HashSum string
|
||||||
HashSum string
|
Owner user.ID
|
||||||
Owner user.ID
|
Headers map[string]string
|
||||||
Headers map[string]string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketSettings stores settings such as versioning.
|
// BucketSettings stores settings such as versioning.
|
||||||
|
|
|
@ -17,7 +17,6 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-s3-gw/api/cache"
|
"github.com/nspcc-dev/neofs-s3-gw/api/cache"
|
||||||
"github.com/nspcc-dev/neofs-s3-gw/api/data"
|
"github.com/nspcc-dev/neofs-s3-gw/api/data"
|
||||||
apiErrors "github.com/nspcc-dev/neofs-s3-gw/api/errors"
|
apiErrors "github.com/nspcc-dev/neofs-s3-gw/api/errors"
|
||||||
"github.com/nspcc-dev/neofs-s3-gw/internal/misc"
|
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/client"
|
"github.com/nspcc-dev/neofs-sdk-go/client"
|
||||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||||
"github.com/nspcc-dev/neofs-sdk-go/object"
|
"github.com/nspcc-dev/neofs-sdk-go/object"
|
||||||
|
@ -183,14 +182,6 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Object
|
||||||
return nil, fmt.Errorf("couldn't add new verion to tree service: %w", err)
|
return nil, fmt.Errorf("couldn't add new verion to tree service: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
currentEpoch, _, err := n.neoFS.TimeToEpoch(ctx, time.Now().Add(time.Minute))
|
|
||||||
if err != nil {
|
|
||||||
n.log.Warn("couldn't get creation epoch",
|
|
||||||
zap.String("bucket", p.BktInfo.Name),
|
|
||||||
zap.String("object", misc.SanitizeString(p.Object)),
|
|
||||||
zap.Error(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.Lock != nil && (p.Lock.Retention != nil || p.Lock.LegalHold != nil) {
|
if p.Lock != nil && (p.Lock.Retention != nil || p.Lock.LegalHold != nil) {
|
||||||
objVersion := &ObjectVersion{
|
objVersion := &ObjectVersion{
|
||||||
BktInfo: p.BktInfo,
|
BktInfo: p.BktInfo,
|
||||||
|
@ -209,15 +200,14 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Object
|
||||||
ID: *id,
|
ID: *id,
|
||||||
CID: p.BktInfo.CID,
|
CID: p.BktInfo.CID,
|
||||||
|
|
||||||
Owner: own,
|
Owner: own,
|
||||||
Bucket: p.BktInfo.Name,
|
Bucket: p.BktInfo.Name,
|
||||||
Name: p.Object,
|
Name: p.Object,
|
||||||
Size: p.Size,
|
Size: p.Size,
|
||||||
Created: time.Now(),
|
Created: time.Now(),
|
||||||
CreationEpoch: currentEpoch,
|
Headers: p.Header,
|
||||||
Headers: p.Header,
|
ContentType: p.Header[api.ContentType],
|
||||||
ContentType: p.Header[api.ContentType],
|
HashSum: hex.EncodeToString(hash),
|
||||||
HashSum: hex.EncodeToString(hash),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = n.objCache.PutObject(objInfo); err != nil {
|
if err = n.objCache.PutObject(objInfo); err != nil {
|
||||||
|
|
|
@ -120,15 +120,14 @@ func objectInfoFromMeta(bkt *data.BucketInfo, meta *object.Object, prefix, delim
|
||||||
CID: bkt.CID,
|
CID: bkt.CID,
|
||||||
IsDir: isDir,
|
IsDir: isDir,
|
||||||
|
|
||||||
Bucket: bkt.Name,
|
Bucket: bkt.Name,
|
||||||
Name: filename,
|
Name: filename,
|
||||||
Created: creation,
|
Created: creation,
|
||||||
CreationEpoch: meta.CreationEpoch(),
|
ContentType: mimeType,
|
||||||
ContentType: mimeType,
|
Headers: userHeaders,
|
||||||
Headers: userHeaders,
|
Owner: *meta.OwnerID(),
|
||||||
Owner: *meta.OwnerID(),
|
Size: size,
|
||||||
Size: size,
|
HashSum: hex.EncodeToString(payloadChecksum.Value()),
|
||||||
HashSum: hex.EncodeToString(payloadChecksum.Value()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue