forked from TrueCloudLab/frostfs-node
c8911d72d0
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
30 lines
713 B
Go
30 lines
713 B
Go
package shard
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
|
)
|
|
|
|
// Lock marks objects as locked with another object. All objects from the
|
|
// specified container.
|
|
//
|
|
// Allows locking regular objects only (otherwise returns apistatus.LockNonRegularObject).
|
|
//
|
|
// Locked list should be unique. Panics if it is empty.
|
|
func (s *Shard) Lock(idCnr cid.ID, locker oid.ID, locked []oid.ID) error {
|
|
m := s.GetMode()
|
|
if m.ReadOnly() {
|
|
return ErrReadOnlyMode
|
|
} else if m.NoMetabase() {
|
|
return ErrDegradedMode
|
|
}
|
|
|
|
err := s.metaBase.Lock(idCnr, locker, locked)
|
|
if err != nil {
|
|
return fmt.Errorf("metabase lock: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|