[#XX] object: Add restrictions for Patch method
Some checks failed
DCO action / DCO (pull_request) Failing after 1m11s
Tests and linters / Run gofumpt (pull_request) Successful in 1m46s
Tests and linters / Lint (pull_request) Failing after 2m21s
Vulncheck / Vulncheck (pull_request) Successful in 2m20s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m29s
Tests and linters / Staticcheck (pull_request) Failing after 2m25s
Build / Build Components (pull_request) Successful in 3m41s
Tests and linters / gopls check (pull_request) Successful in 4m4s
Tests and linters / Tests (pull_request) Successful in 6m15s
Tests and linters / Tests with -race (pull_request) Successful in 6m21s

* `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:
Airat Arifullin 2024-09-18 12:13:15 +03:00
parent d4bec24c9f
commit 65460e7ced

View file

@ -63,6 +63,14 @@ func (s *Streamer) init(ctx context.Context, req *objectV2.PatchRequest) error {
return err return err
} }
if hdrWithSig.GetHeader().GetObjectType() != objectV2.TypeRegular {
return errors.New("non-regular object can't be patched")
}
if hdrWithSig.GetHeader().GetEC() != nil || hdrWithSig.GetHeader().GetSplit() != nil {
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