object: Add restrictions for Patch method #1383

Merged
dstepanov-yadro merged 1 commit from aarifullin/frostfs-node:fix/patch/5 into master 2024-09-19 12:05:50 +00:00

View file

@ -57,12 +57,31 @@ func toFullObjectHeader(hdr *objectSDK.Object) objectV2.GetHeaderPart {
return hs
}
func isLinkObject(hdr *objectV2.HeaderWithSignature) bool {
split := hdr.GetHeader().GetSplit()
return len(split.GetChildren()) > 0 && split.GetParent() != nil
}
func isComplexObjectPart(hdr *objectV2.HeaderWithSignature) bool {
return hdr.GetHeader().GetEC() != nil || hdr.GetHeader().GetSplit() != nil
}
func (s *Streamer) init(ctx context.Context, req *objectV2.PatchRequest) error {
hdrWithSig, addr, err := s.readHeader(ctx, req)
if err != nil {
return err
}
if hdrWithSig.GetHeader().GetObjectType() != objectV2.TypeRegular {
return errors.New("non-regular object can't be patched")
}
if isLinkObject(hdrWithSig) {
return errors.New("linking object can't be patched")
}
if isComplexObjectPart(hdrWithSig) {
return errors.New("complex object parts can't be patched")
}
commonPrm, err := util.CommonPrmFromV2(req)
if err != nil {
return err