[#1461] node: Allow force LOCK removal

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-05-31 23:11:42 +03:00 committed by fyrchik
parent 25826bd96d
commit 9c5ef3bab8
4 changed files with 64 additions and 2 deletions

View file

@ -11,6 +11,8 @@ import (
// DeletePrm groups the parameters of Delete operation.
type DeletePrm struct {
addr []oid.Address
forceRemoval bool
}
// DeleteRes groups the resulting values of Delete operation.
@ -25,6 +27,15 @@ func (p *DeletePrm) WithAddresses(addr ...oid.Address) {
}
}
// WithForceRemoval is a Delete option to remove an object despite any
// restrictions imposed on deleting that object. Expected to be used
// only in control service.
func (p *DeletePrm) WithForceRemoval() {
if p != nil {
p.forceRemoval = true
}
}
// Delete marks the objects to be removed.
//
// Returns an error if executions are blocked (see BlockExecution).
@ -65,6 +76,9 @@ func (e *StorageEngine) delete(prm DeletePrm) (DeleteRes, error) {
var shPrm shard.InhumePrm
shPrm.MarkAsGarbage(prm.addr[i])
if prm.forceRemoval {
shPrm.ForceRemoval()
}
_, err = sh.Inhume(shPrm)
if err != nil {