[#1338] object: Fix range provider in Patch
handler
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m35s
DCO action / DCO (pull_request) Successful in 1m43s
Vulncheck / Vulncheck (pull_request) Successful in 2m26s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m41s
Build / Build Components (1.22) (pull_request) Successful in 2m35s
Tests and linters / Tests (1.22) (pull_request) Successful in 2m50s
Build / Build Components (1.23) (pull_request) Successful in 2m39s
Tests and linters / Tests (1.23) (pull_request) Successful in 3m20s
Tests and linters / Staticcheck (pull_request) Successful in 3m24s
Tests and linters / Lint (pull_request) Successful in 3m41s
Tests and linters / gopls check (pull_request) Successful in 3m52s
Tests and linters / Tests with -race (pull_request) Successful in 4m3s
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m35s
DCO action / DCO (pull_request) Successful in 1m43s
Vulncheck / Vulncheck (pull_request) Successful in 2m26s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m41s
Build / Build Components (1.22) (pull_request) Successful in 2m35s
Tests and linters / Tests (1.22) (pull_request) Successful in 2m50s
Build / Build Components (1.23) (pull_request) Successful in 2m39s
Tests and linters / Tests (1.23) (pull_request) Successful in 3m20s
Tests and linters / Staticcheck (pull_request) Successful in 3m24s
Tests and linters / Lint (pull_request) Successful in 3m41s
Tests and linters / gopls check (pull_request) Successful in 3m52s
Tests and linters / Tests with -race (pull_request) Successful in 4m3s
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
d6b42972a8
commit
aaa7b7238e
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