forked from TrueCloudLab/frostfs-node
[#52] object/range: Add full range option to parameters
Add FullRange option to get range operation parameters that allows to get payload range [0:object_size] w/o the actual knowledge of the object size. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
abf9ad3573
commit
3880315a3f
2 changed files with 16 additions and 4 deletions
|
@ -64,12 +64,16 @@ func (s *Service) GetRange(ctx context.Context, prm *Prm) (*Result, error) {
|
|||
return nil, errors.Wrapf(err, "(%T) could not receive Head result", s)
|
||||
}
|
||||
|
||||
off, ln := prm.rng.GetOffset(), prm.rng.GetLength()
|
||||
|
||||
origin := headResult.Header()
|
||||
|
||||
originSize := origin.GetPayloadSize()
|
||||
if originSize < off+ln {
|
||||
|
||||
if prm.full {
|
||||
prm.rng = new(object.Range)
|
||||
prm.rng.SetLength(originSize)
|
||||
}
|
||||
|
||||
if originSize < prm.rng.GetOffset()+prm.rng.GetLength() {
|
||||
return nil, errors.Errorf("(%T) requested payload range is out-of-bounds", s)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue