[#1383] object: Add restrictions for Patch
method
All checks were successful
DCO action / DCO (pull_request) Successful in 58s
Tests and linters / Run gofumpt (pull_request) Successful in 1m15s
Vulncheck / Vulncheck (pull_request) Successful in 1m26s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m6s
Build / Build Components (pull_request) Successful in 2m20s
Tests and linters / gopls check (pull_request) Successful in 2m34s
Tests and linters / Staticcheck (pull_request) Successful in 2m49s
Tests and linters / Lint (pull_request) Successful in 3m41s
Tests and linters / Tests (pull_request) Successful in 4m46s
Tests and linters / Tests with -race (pull_request) Successful in 4m58s
All checks were successful
DCO action / DCO (pull_request) Successful in 58s
Tests and linters / Run gofumpt (pull_request) Successful in 1m15s
Vulncheck / Vulncheck (pull_request) Successful in 1m26s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m6s
Build / Build Components (pull_request) Successful in 2m20s
Tests and linters / gopls check (pull_request) Successful in 2m34s
Tests and linters / Staticcheck (pull_request) Successful in 2m49s
Tests and linters / Lint (pull_request) Successful in 3m41s
Tests and linters / Tests (pull_request) Successful in 4m46s
Tests and linters / Tests with -race (pull_request) Successful in 4m58s
* `Patch` can't be applied for non-regular type object (tombstones, locks etc.) * Complex object parts can't be patched. So, if an object has EC/Split header, it won't be patched. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
3441fff05d
commit
61d5e140e0
1 changed files with 19 additions and 0 deletions
|
@ -57,12 +57,31 @@ func toFullObjectHeader(hdr *objectSDK.Object) objectV2.GetHeaderPart {
|
||||||
return hs
|
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 {
|
func (s *Streamer) init(ctx context.Context, req *objectV2.PatchRequest) error {
|
||||||
hdrWithSig, addr, err := s.readHeader(ctx, req)
|
hdrWithSig, addr, err := s.readHeader(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
commonPrm, err := util.CommonPrmFromV2(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue