[#542] Handle unversioned mode

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-07-01 12:32:31 +03:00 committed by Alex Vanin
parent fdf0974679
commit f1a0288e3a
2 changed files with 18 additions and 1 deletions

View file

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

View file

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