[#230] engine: Stop on first SplitInfoError in Get method

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-12-03 13:01:09 +03:00
parent a488d202e1
commit 3a37eda410
3 changed files with 14 additions and 23 deletions

View file

@ -43,9 +43,10 @@ func (r *GetRes) Object() *object.Object {
// Returns ErrNotFound if requested object is missing in local storage.
func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) {
var (
obj *object.Object
obj *object.Object
siErr *objectSDK.SplitInfoError
alreadyRemoved = false
outError = object.ErrNotFound
)
shPrm := new(shard.GetPrm).
@ -57,8 +58,10 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) {
switch {
case errors.Is(err, object.ErrNotFound):
return false // ignore, go to next shard
case errors.Is(err, object.ErrAlreadyRemoved):
alreadyRemoved = true
case
errors.Is(err, object.ErrAlreadyRemoved),
errors.As(err, &siErr):
outError = err
return true // stop, return it back
default:
@ -79,11 +82,7 @@ func (e *StorageEngine) Get(prm *GetPrm) (*GetRes, error) {
})
if obj == nil {
if alreadyRemoved {
return nil, object.ErrAlreadyRemoved
}
return nil, object.ErrNotFound
return nil, outError
}
return &GetRes{

View file

@ -46,7 +46,7 @@ func (e *StorageEngine) Head(prm *HeadPrm) (*HeadRes, error) {
var (
head *object.Object
alreadyRemoved = false
outError = object.ErrNotFound
)
shPrm := new(shard.HeadPrm).
@ -59,7 +59,7 @@ func (e *StorageEngine) Head(prm *HeadPrm) (*HeadRes, error) {
case errors.Is(err, object.ErrNotFound):
return false // ignore, go to next shard
case errors.Is(err, object.ErrAlreadyRemoved):
alreadyRemoved = true
outError = err
return true // stop, return it back
default:
@ -80,11 +80,7 @@ func (e *StorageEngine) Head(prm *HeadPrm) (*HeadRes, error) {
})
if head == nil {
if alreadyRemoved {
return nil, object.ErrAlreadyRemoved
}
return nil, object.ErrNotFound
return nil, outError
}
return &HeadRes{

View file

@ -61,7 +61,7 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
var (
obj *object.Object
alreadyRemoved = false
outError = object.ErrNotFound
)
shPrm := new(shard.RngPrm).
@ -75,7 +75,7 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
case errors.Is(err, object.ErrNotFound):
return false // ignore, go to next shard
case errors.Is(err, object.ErrAlreadyRemoved):
alreadyRemoved = true
outError = err
return true // stop, return it back
default:
@ -96,11 +96,7 @@ func (e *StorageEngine) GetRange(prm *RngPrm) (*RngRes, error) {
})
if obj == nil {
if alreadyRemoved {
return nil, object.ErrAlreadyRemoved
}
return nil, object.ErrNotFound
return nil, outError
}
return &RngRes{