[#1745] writecache: Remove IsErrNotFound
We specify the error in the doc-comment, and it is the same for all our components. Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
9e41e85295
commit
c04126f35e
4 changed files with 3 additions and 18 deletions
|
@ -3,7 +3,6 @@ package shard
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
|
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
|
||||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
|
|
||||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -40,7 +39,7 @@ func (s *Shard) Delete(prm DeletePrm) (DeleteRes, error) {
|
||||||
for i := range prm.addr {
|
for i := range prm.addr {
|
||||||
if s.hasWriteCache() {
|
if s.hasWriteCache() {
|
||||||
err := s.writeCache.Delete(prm.addr[i])
|
err := s.writeCache.Delete(prm.addr[i])
|
||||||
if err != nil && !writecache.IsErrNotFound(err) {
|
if err != nil && !IsErrNotFound(err) {
|
||||||
s.log.Error("can't delete object from write cache", zap.String("error", err.Error()))
|
s.log.Error("can't delete object from write cache", zap.String("error", err.Error()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ func (s *Shard) fetchObjectData(addr oid.Address, skipMeta bool, cb storFetcher,
|
||||||
return res, false, err
|
return res, false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if writecache.IsErrNotFound(err) {
|
if IsErrNotFound(err) {
|
||||||
s.log.Debug("object is missing in write-cache")
|
s.log.Debug("object is missing in write-cache")
|
||||||
} else {
|
} else {
|
||||||
s.log.Error("failed to fetch object from write-cache", zap.Error(err))
|
s.log.Error("failed to fetch object from write-cache", zap.Error(err))
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
|
|
||||||
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
|
||||||
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
||||||
)
|
)
|
||||||
|
@ -56,7 +55,7 @@ func (s *Shard) Head(prm HeadPrm) (HeadRes, error) {
|
||||||
return HeadRes{
|
return HeadRes{
|
||||||
obj: header,
|
obj: header,
|
||||||
}, nil
|
}, nil
|
||||||
} else if !writecache.IsErrNotFound(err) {
|
} else if !IsErrNotFound(err) {
|
||||||
// in this case we think that object is presented in write-cache, but corrupted
|
// in this case we think that object is presented in write-cache, but corrupted
|
||||||
return HeadRes{}, fmt.Errorf("could not read header from write-cache: %w", err)
|
return HeadRes{}, fmt.Errorf("could not read header from write-cache: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package writecache
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
|
|
||||||
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsErrNotFound checks if error returned by Cache Get/Head/Delete method
|
|
||||||
// corresponds to missing object.
|
|
||||||
func IsErrNotFound(err error) bool {
|
|
||||||
return errors.As(err, new(apistatus.ObjectNotFound))
|
|
||||||
}
|
|
Loading…
Reference in a new issue