From c04126f35e1f2d3d73b597f8661dafb94ab14f34 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 1 Sep 2022 09:16:50 +0300 Subject: [PATCH] [#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 --- pkg/local_object_storage/shard/delete.go | 3 +-- pkg/local_object_storage/shard/get.go | 2 +- pkg/local_object_storage/shard/head.go | 3 +-- pkg/local_object_storage/writecache/errors.go | 13 ------------- 4 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 pkg/local_object_storage/writecache/errors.go diff --git a/pkg/local_object_storage/shard/delete.go b/pkg/local_object_storage/shard/delete.go index 3115dadac..b1c3c81ac 100644 --- a/pkg/local_object_storage/shard/delete.go +++ b/pkg/local_object_storage/shard/delete.go @@ -3,7 +3,6 @@ package shard import ( "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common" 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" "go.uber.org/zap" ) @@ -40,7 +39,7 @@ func (s *Shard) Delete(prm DeletePrm) (DeleteRes, error) { for i := range prm.addr { if s.hasWriteCache() { 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())) } } diff --git a/pkg/local_object_storage/shard/get.go b/pkg/local_object_storage/shard/get.go index 7beb6bdac..bbc16cddf 100644 --- a/pkg/local_object_storage/shard/get.go +++ b/pkg/local_object_storage/shard/get.go @@ -100,7 +100,7 @@ func (s *Shard) fetchObjectData(addr oid.Address, skipMeta bool, cb storFetcher, return res, false, err } - if writecache.IsErrNotFound(err) { + if IsErrNotFound(err) { s.log.Debug("object is missing in write-cache") } else { s.log.Error("failed to fetch object from write-cache", zap.Error(err)) diff --git a/pkg/local_object_storage/shard/head.go b/pkg/local_object_storage/shard/head.go index 60e1db4d5..73896383e 100644 --- a/pkg/local_object_storage/shard/head.go +++ b/pkg/local_object_storage/shard/head.go @@ -4,7 +4,6 @@ import ( "fmt" 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" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" ) @@ -56,7 +55,7 @@ func (s *Shard) Head(prm HeadPrm) (HeadRes, error) { return HeadRes{ obj: header, }, nil - } else if !writecache.IsErrNotFound(err) { + } else if !IsErrNotFound(err) { // 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) } diff --git a/pkg/local_object_storage/writecache/errors.go b/pkg/local_object_storage/writecache/errors.go deleted file mode 100644 index ef9feea9e..000000000 --- a/pkg/local_object_storage/writecache/errors.go +++ /dev/null @@ -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)) -}