[#1247] object: Return NOT_FOUND and ALREADY_REMOVED statuses

Replace `ErrNotFound`/`ErrAlreadyRemoved` error from
`pkg/core/object` package with `ObjectNotFound`/`ObjectAlreadyRemoved`
one from `apistatus` package. These errors are returned by storage
node's server as NeoFS API statuses.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-03-17 11:03:58 +03:00 committed by Alex Vanin
parent f32c9670ad
commit 70ffdf3478
49 changed files with 348 additions and 178 deletions

View file

@ -1,10 +1,8 @@
package engine
import (
"errors"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
addressSDK "github.com/nspcc-dev/neofs-sdk-go/object/address"
)
@ -16,7 +14,7 @@ func (e *StorageEngine) exists(addr *addressSDK.Address) (bool, error) {
e.iterateOverSortedShards(addr, func(_ int, sh hashedShard) (stop bool) {
res, err := sh.Exists(shPrm)
if err != nil {
if errors.Is(err, object.ErrAlreadyRemoved) {
if shard.IsErrRemoved(err) {
alreadyRemoved = true
return true
@ -33,7 +31,9 @@ func (e *StorageEngine) exists(addr *addressSDK.Address) (bool, error) {
})
if alreadyRemoved {
return false, object.ErrAlreadyRemoved
var errRemoved apistatus.ObjectAlreadyRemoved
return false, errRemoved
}
return exists, nil