diff --git a/api/handler/multipart_upload.go b/api/handler/multipart_upload.go index 5de5815..018f55e 100644 --- a/api/handler/multipart_upload.go +++ b/api/handler/multipart_upload.go @@ -457,7 +457,7 @@ func (h *handler) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http. Key: objInfo.Name, } - if bktSettings != nil && bktSettings.VersioningEnabled { + if bktSettings.VersioningEnabled { w.Header().Set(api.AmzVersionID, objInfo.Version()) } diff --git a/api/layer/layer.go b/api/layer/layer.go index 3842ae5..f3b3074 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -547,14 +547,8 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, settings var ( err error ids []*oid.ID - - versioningEnabled = false ) - if settings != nil { - versioningEnabled = settings.VersioningEnabled - } - p := &PutObjectParams{ BktInfo: bkt, Object: obj.Name, @@ -565,7 +559,7 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, settings // Current implementation doesn't consider "unversioned" mode (so any deletion creates "delete-mark" object). // The reason is difficulties to determinate whether versioning mode is "unversioned" or "suspended". - if obj.VersionID == unversionedObjectVersionID || !versioningEnabled && len(obj.VersionID) == 0 { + if obj.VersionID == unversionedObjectVersionID || !settings.VersioningEnabled && len(obj.VersionID) == 0 { p.Header[versionsUnversionedAttr] = "true" versions, err := n.headVersions(ctx, bkt, obj.Name) if err != nil { @@ -618,7 +612,7 @@ func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, settings } if len(obj.VersionID) == 0 { obj.DeleteMarkVersion = objInfo.Version() - if versioningEnabled { + if settings.VersioningEnabled { obj.DeleteMarkerEtag = objInfo.HashSum } } diff --git a/api/layer/versioning_test.go b/api/layer/versioning_test.go index ca44572..1487169 100644 --- a/api/layer/versioning_test.go +++ b/api/layer/versioning_test.go @@ -10,7 +10,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neofs-s3-gw/api" "github.com/nspcc-dev/neofs-s3-gw/api/data" - "github.com/nspcc-dev/neofs-s3-gw/api/errors" "github.com/nspcc-dev/neofs-s3-gw/api/layer/neofs" "github.com/nspcc-dev/neofs-s3-gw/creds/accessbox" "github.com/nspcc-dev/neofs-s3-gw/internal/neofstest" @@ -360,7 +359,7 @@ func TestNoVersioningDeleteObject(t *testing.T) { tc.putObject([]byte("content obj1 v2")) versioning, err := tc.layer.GetBucketSettings(tc.ctx, tc.bktInfo) - require.Error(t, err, errors.GetAPIError(errors.ErrNoSuchKey)) + require.NoError(t, err) tc.deleteObject(tc.obj, "", versioning) tc.getObject(tc.obj, "", true)