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