[#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:
Alex Vanin 2022-06-03 17:33:47 +03:00 committed by Alex Vanin
parent 9dfc7e043f
commit 4f3d206422
3 changed files with 24 additions and 36 deletions

View file

@ -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.

View file

@ -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 {

View file

@ -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()),
}
}