[#176] shard: Fix BlobStor access when data range is zero
In previous implementation Shard accessed the BlobStor to get the object header. However, the shard must take headers from the metabase. From now zero length of the requested payload range seens as object header request. In this case shard calls metabase to get the header. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
796bba3793
commit
b1718a60e4
1 changed files with 12 additions and 0 deletions
|
@ -49,6 +49,9 @@ func (p *GetPrm) WithFullRange() *GetPrm {
|
||||||
//
|
//
|
||||||
// Calling with negative length is equivalent
|
// Calling with negative length is equivalent
|
||||||
// to getting the full payload range.
|
// to getting the full payload range.
|
||||||
|
//
|
||||||
|
// Calling with zero length is equivalent
|
||||||
|
// to getting the object header.
|
||||||
func (p *GetPrm) WithRange(off uint64, ln int64) *GetPrm {
|
func (p *GetPrm) WithRange(off uint64, ln int64) *GetPrm {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.off, p.ln = off, ln
|
p.off, p.ln = off, ln
|
||||||
|
@ -89,6 +92,15 @@ func (s *Shard) Get(prm *GetPrm) (*GetRes, error) {
|
||||||
return &GetRes{
|
return &GetRes{
|
||||||
obj: res.Object(),
|
obj: res.Object(),
|
||||||
}, nil
|
}, nil
|
||||||
|
} else if prm.ln == 0 {
|
||||||
|
head, err := s.metaBase.Get(prm.addr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &GetRes{
|
||||||
|
obj: head,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to read from WriteCache
|
// try to read from WriteCache
|
||||||
|
|
Loading…
Reference in a new issue