[#XX] object: Fix range provider in Patch
handler
Some checks failed
DCO action / DCO (pull_request) Failing after 1m45s
Tests and linters / Run gofumpt (pull_request) Successful in 1m51s
Build / Build Components (1.22) (pull_request) Successful in 2m20s
Vulncheck / Vulncheck (pull_request) Successful in 2m14s
Build / Build Components (1.23) (pull_request) Successful in 2m43s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m56s
Tests and linters / Tests (1.22) (pull_request) Successful in 2m59s
Tests and linters / Staticcheck (pull_request) Successful in 3m13s
Tests and linters / Tests (1.23) (pull_request) Successful in 3m18s
Tests and linters / gopls check (pull_request) Successful in 3m48s
Tests and linters / Lint (pull_request) Successful in 4m0s
Tests and linters / Tests with -race (pull_request) Successful in 4m1s
Some checks failed
DCO action / DCO (pull_request) Failing after 1m45s
Tests and linters / Run gofumpt (pull_request) Successful in 1m51s
Build / Build Components (1.22) (pull_request) Successful in 2m20s
Vulncheck / Vulncheck (pull_request) Successful in 2m14s
Build / Build Components (1.23) (pull_request) Successful in 2m43s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m56s
Tests and linters / Tests (1.22) (pull_request) Successful in 2m59s
Tests and linters / Staticcheck (pull_request) Successful in 3m13s
Tests and linters / Tests (1.23) (pull_request) Successful in 3m18s
Tests and linters / gopls check (pull_request) Successful in 3m48s
Tests and linters / Lint (pull_request) Successful in 4m0s
Tests and linters / Tests with -race (pull_request) Successful in 4m1s
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
d11535c344
commit
aa602c36d8
2 changed files with 17 additions and 1 deletions
|
@ -25,11 +25,19 @@ type rangeProvider struct {
|
|||
commonPrm *objectUtil.CommonPrm
|
||||
|
||||
localNodeKey *ecdsa.PrivateKey
|
||||
|
||||
originalPayloadLength uint64
|
||||
}
|
||||
|
||||
var _ patcherSDK.RangeProvider = (*rangeProvider)(nil)
|
||||
|
||||
func (r *rangeProvider) GetRange(ctx context.Context, rng *objectSDK.Range) io.Reader {
|
||||
// Remote GetRange request to a container node uses an SDK-client that fails range validation
|
||||
// with zero-length. However, from the patcher's point of view, such request is still valid.
|
||||
if rng.GetOffset() == r.originalPayloadLength && rng.GetLength() == 0 {
|
||||
return &nopReader{}
|
||||
}
|
||||
|
||||
pipeReader, pipeWriter := io.Pipe()
|
||||
|
||||
var rngPrm getsvc.RangePrm
|
||||
|
@ -61,3 +69,9 @@ func (r *rangeProvider) GetRange(ctx context.Context, rng *objectSDK.Range) io.R
|
|||
|
||||
return pipeReader
|
||||
}
|
||||
|
||||
type nopReader struct{}
|
||||
|
||||
func (nopReader) Read(_ []byte) (int, error) {
|
||||
return 0, io.EOF
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ func (s *Streamer) init(ctx context.Context, req *objectV2.PatchRequest) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hdr := hdrWithSig.GetHeader()
|
||||
|
||||
commonPrm, err := util.CommonPrmFromV2(req)
|
||||
if err != nil {
|
||||
|
@ -76,6 +77,8 @@ func (s *Streamer) init(ctx context.Context, req *objectV2.PatchRequest) error {
|
|||
commonPrm: commonPrm,
|
||||
|
||||
localNodeKey: s.localNodeKey,
|
||||
|
||||
originalPayloadLength: hdr.GetPayloadLength(),
|
||||
}
|
||||
|
||||
putstm, err := s.putSvc.Put()
|
||||
|
@ -83,7 +86,6 @@ func (s *Streamer) init(ctx context.Context, req *objectV2.PatchRequest) error {
|
|||
return err
|
||||
}
|
||||
|
||||
hdr := hdrWithSig.GetHeader()
|
||||
oV2 := new(objectV2.Object)
|
||||
hV2 := new(objectV2.Header)
|
||||
oV2.SetHeader(hV2)
|
||||
|
|
Loading…
Reference in a new issue