forked from TrueCloudLab/frostfs-node
[#80] core/object: Add SG-object format validation
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f7ca4a8dce
commit
8c4e033db3
2 changed files with 44 additions and 0 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/storagegroup"
|
||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -140,6 +141,22 @@ func (v *FormatValidator) ValidateContent(o *Object) error {
|
|||
if v.deleteHandler != nil {
|
||||
v.deleteHandler.DeleteObjects(o.Address(), addrList...)
|
||||
}
|
||||
case object.TypeStorageGroup:
|
||||
if len(o.Payload()) == 0 {
|
||||
return errors.Errorf("(%T) empty payload in SG", v)
|
||||
}
|
||||
|
||||
sg := storagegroup.New()
|
||||
|
||||
if err := sg.Unmarshal(o.Payload()); err != nil {
|
||||
return errors.Wrapf(err, "(%T) could not unmarshal SG content", v)
|
||||
}
|
||||
|
||||
for _, id := range sg.Members() {
|
||||
if id == nil {
|
||||
return errors.Errorf("(%T) empty member in SG", v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue