From 4f3d2064226a0976429d22af262ad8730a2e7866 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Fri, 3 Jun 2022 17:33:47 +0300 Subject: [PATCH] [#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 --- api/data/info.go | 17 ++++++++--------- api/layer/object.go | 26 ++++++++------------------ api/layer/util.go | 17 ++++++++--------- 3 files changed, 24 insertions(+), 36 deletions(-) diff --git a/api/data/info.go b/api/data/info.go index e005c997..e4ed76c2 100644 --- a/api/data/info.go +++ b/api/data/info.go @@ -33,15 +33,14 @@ type ( IsDir bool IsDeleteMarker bool - Bucket string - Name string - Size int64 - ContentType string - Created time.Time - CreationEpoch uint64 - HashSum string - Owner user.ID - Headers map[string]string + Bucket string + Name string + Size int64 + ContentType string + Created time.Time + HashSum string + Owner user.ID + Headers map[string]string } // BucketSettings stores settings such as versioning. diff --git a/api/layer/object.go b/api/layer/object.go index 9aab0903..711e137b 100644 --- a/api/layer/object.go +++ b/api/layer/object.go @@ -17,7 +17,6 @@ import ( "github.com/nspcc-dev/neofs-s3-gw/api/cache" "github.com/nspcc-dev/neofs-s3-gw/api/data" 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" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" "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) } - 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) { objVersion := &ObjectVersion{ BktInfo: p.BktInfo, @@ -209,15 +200,14 @@ func (n *layer) PutObject(ctx context.Context, p *PutObjectParams) (*data.Object ID: *id, CID: p.BktInfo.CID, - Owner: own, - Bucket: p.BktInfo.Name, - Name: p.Object, - Size: p.Size, - Created: time.Now(), - CreationEpoch: currentEpoch, - Headers: p.Header, - ContentType: p.Header[api.ContentType], - HashSum: hex.EncodeToString(hash), + Owner: own, + Bucket: p.BktInfo.Name, + Name: p.Object, + Size: p.Size, + Created: time.Now(), + Headers: p.Header, + ContentType: p.Header[api.ContentType], + HashSum: hex.EncodeToString(hash), } if err = n.objCache.PutObject(objInfo); err != nil { diff --git a/api/layer/util.go b/api/layer/util.go index 80e13a53..1df46368 100644 --- a/api/layer/util.go +++ b/api/layer/util.go @@ -120,15 +120,14 @@ func objectInfoFromMeta(bkt *data.BucketInfo, meta *object.Object, prefix, delim CID: bkt.CID, IsDir: isDir, - Bucket: bkt.Name, - Name: filename, - Created: creation, - CreationEpoch: meta.CreationEpoch(), - ContentType: mimeType, - Headers: userHeaders, - Owner: *meta.OwnerID(), - Size: size, - HashSum: hex.EncodeToString(payloadChecksum.Value()), + Bucket: bkt.Name, + Name: filename, + Created: creation, + ContentType: mimeType, + Headers: userHeaders, + Owner: *meta.OwnerID(), + Size: size, + HashSum: hex.EncodeToString(payloadChecksum.Value()), } }