From f1a0288e3a7ac72167055348997ffcb94578dd13 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Fri, 1 Jul 2022 12:32:31 +0300 Subject: [PATCH] [#542] Handle unversioned mode Signed-off-by: Denis Kirillov --- api/handler/delete_test.go | 17 +++++++++++++++++ api/layer/layer.go | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/api/handler/delete_test.go b/api/handler/delete_test.go index 70e93921a..45ae8f707 100644 --- a/api/handler/delete_test.go +++ b/api/handler/delete_test.go @@ -44,6 +44,23 @@ func TestDeleteObjectVersioned(t *testing.T) { require.False(t, existInMockedNeoFS(tc, bktInfo, objInfo), "object exists but shouldn't") } +func TestDeleteObjectUnversioned(t *testing.T) { + tc := prepareHandlerContext(t) + + bktName, objName := "bucket-for-removal-unversioned", "object-to-delete-unversioned" + bktInfo, objInfo := createBucketAndObject(t, tc, bktName, objName) + + checkFound(t, tc, bktName, objName, emptyVersion) + deleteObject(t, tc, bktName, objName, emptyVersion) + checkNotFound(t, tc, bktName, objName, emptyVersion) + + versions := listVersions(t, tc, bktName) + require.Len(t, versions.DeleteMarker, 0, "delete markers must be empty") + require.Len(t, versions.Version, 0, "versions must be empty") + + require.False(t, existInMockedNeoFS(tc, bktInfo, objInfo), "object exists but shouldn't") +} + func TestRemoveDeleteMarker(t *testing.T) { tc := prepareHandlerContext(t) diff --git a/api/layer/layer.go b/api/layer/layer.go index b66b9f4f9..8c6dab499 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -475,7 +475,7 @@ func getRandomOID() (oid.ID, error) { } func (n *layer) deleteObject(ctx context.Context, bkt *data.BucketInfo, settings *data.BucketSettings, obj *VersionedObject) *VersionedObject { - if len(obj.VersionID) != 0 { + if len(obj.VersionID) != 0 || settings.IsNoneStatus { var nodeVersion *data.NodeVersion if nodeVersion, obj.Error = n.getNodeVersionToDelete(ctx, bkt, obj); obj.Error != nil { return obj