2022-02-15 22:20:44 +00:00
|
|
|
package shard
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2022-06-28 14:05:08 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard/mode"
|
2022-02-15 22:20:44 +00:00
|
|
|
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.
|
|
|
|
//
|
2022-03-05 08:46:02 +00:00
|
|
|
// Allows locking regular objects only (otherwise returns apistatus.LockNonRegularObject).
|
2022-02-15 22:20:44 +00:00
|
|
|
//
|
|
|
|
// Locked list should be unique. Panics if it is empty.
|
|
|
|
func (s *Shard) Lock(idCnr cid.ID, locker oid.ID, locked []oid.ID) error {
|
2022-06-28 14:05:08 +00:00
|
|
|
if s.GetMode() != mode.ReadWrite {
|
2022-02-15 22:20:44 +00:00
|
|
|
return ErrReadOnlyMode
|
|
|
|
}
|
|
|
|
|
|
|
|
err := s.metaBase.Lock(idCnr, locker, locked)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("metabase lock: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|