diff --git a/pkg/core/object/errors.go b/pkg/core/object/errors.go deleted file mode 100644 index c4c99c65e..000000000 --- a/pkg/core/object/errors.go +++ /dev/null @@ -1,10 +0,0 @@ -package object - -import ( - "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr" -) - -// ErrObjectIsExpired is returned when the requested object's -// epoch is less than the current one. Such objects are considered -// as removed and should not be returned from the Storage Engine. -var ErrObjectIsExpired = logicerr.New("object is expired") diff --git a/pkg/local_object_storage/metabase/counter_test.go b/pkg/local_object_storage/metabase/counter_test.go index 3f8547e2e..0604d7e0c 100644 --- a/pkg/local_object_storage/metabase/counter_test.go +++ b/pkg/local_object_storage/metabase/counter_test.go @@ -211,7 +211,7 @@ func TestCounters_Expired(t *testing.T) { for _, o := range oo { _, err := metaGet(db, o, true) - require.ErrorIs(t, err, objectcore.ErrObjectIsExpired) + require.ErrorIs(t, err, meta.ErrObjectIsExpired) } // 3. inhuming an expired object with GCMark (like it would diff --git a/pkg/local_object_storage/metabase/errors.go b/pkg/local_object_storage/metabase/errors.go index 927cbf83b..c02e0f498 100644 --- a/pkg/local_object_storage/metabase/errors.go +++ b/pkg/local_object_storage/metabase/errors.go @@ -3,9 +3,15 @@ package meta import ( "errors" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" ) +// ErrObjectIsExpired is returned when the requested object's +// epoch is less than the current one. Such objects are considered +// as removed and should not be returned from the Storage Engine. +var ErrObjectIsExpired = logicerr.New("object is expired") + // IsErrRemoved checks if error returned by Shard Exists/Get/Put method // corresponds to removed object. func IsErrRemoved(err error) bool { diff --git a/pkg/local_object_storage/metabase/exists.go b/pkg/local_object_storage/metabase/exists.go index 825ec5118..efd77066d 100644 --- a/pkg/local_object_storage/metabase/exists.go +++ b/pkg/local_object_storage/metabase/exists.go @@ -5,7 +5,6 @@ import ( "strconv" objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object" - "github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" @@ -64,7 +63,7 @@ func (db *DB) exists(tx *bbolt.Tx, addr oid.Address, currEpoch uint64) (exists b case 2: return false, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{}) case 3: - return false, object.ErrObjectIsExpired + return false, ErrObjectIsExpired } objKey := objectKey(addr.Object(), make([]byte, objectKeySize)) diff --git a/pkg/local_object_storage/metabase/exists_test.go b/pkg/local_object_storage/metabase/exists_test.go index ca8f829f1..e5c3245d4 100644 --- a/pkg/local_object_storage/metabase/exists_test.go +++ b/pkg/local_object_storage/metabase/exists_test.go @@ -177,7 +177,7 @@ func TestDB_Exists(t *testing.T) { checkExpiredObjects(t, db, func(exp, nonExp *objectSDK.Object) { gotObj, err := metaExists(db, object.AddressOf(exp)) require.False(t, gotObj) - require.ErrorIs(t, err, object.ErrObjectIsExpired) + require.ErrorIs(t, err, meta.ErrObjectIsExpired) gotObj, err = metaExists(db, object.AddressOf(nonExp)) require.True(t, gotObj) diff --git a/pkg/local_object_storage/metabase/get.go b/pkg/local_object_storage/metabase/get.go index b3e008adb..b4d399a9b 100644 --- a/pkg/local_object_storage/metabase/get.go +++ b/pkg/local_object_storage/metabase/get.go @@ -3,7 +3,6 @@ package meta import ( "fmt" - "github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/util/logicerr" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" @@ -71,7 +70,7 @@ func (db *DB) get(tx *bbolt.Tx, addr oid.Address, key []byte, checkStatus, raw b case 2: return nil, logicerr.Wrap(apistatus.ObjectAlreadyRemoved{}) case 3: - return nil, object.ErrObjectIsExpired + return nil, ErrObjectIsExpired } } diff --git a/pkg/local_object_storage/metabase/get_test.go b/pkg/local_object_storage/metabase/get_test.go index 38842a663..b284836ef 100644 --- a/pkg/local_object_storage/metabase/get_test.go +++ b/pkg/local_object_storage/metabase/get_test.go @@ -139,7 +139,7 @@ func TestDB_Get(t *testing.T) { checkExpiredObjects(t, db, func(exp, nonExp *objectSDK.Object) { gotExp, err := metaGet(db, object.AddressOf(exp), false) require.Nil(t, gotExp) - require.ErrorIs(t, err, object.ErrObjectIsExpired) + require.ErrorIs(t, err, meta.ErrObjectIsExpired) gotNonExp, err := metaGet(db, object.AddressOf(nonExp), false) require.NoError(t, err) diff --git a/pkg/local_object_storage/shard/control.go b/pkg/local_object_storage/shard/control.go index 1378d4979..22e64b91f 100644 --- a/pkg/local_object_storage/shard/control.go +++ b/pkg/local_object_storage/shard/control.go @@ -223,7 +223,7 @@ func (s *Shard) refillMetabase() error { mPrm.SetStorageID(descriptor) _, err := s.metaBase.Put(mPrm) - if err != nil && !meta.IsErrRemoved(err) && !errors.Is(err, object.ErrObjectIsExpired) { + if err != nil && !meta.IsErrRemoved(err) && !errors.Is(err, meta.ErrObjectIsExpired) { return err } diff --git a/pkg/local_object_storage/shard/errors.go b/pkg/local_object_storage/shard/errors.go index 3aa3ddc83..31cd5836a 100644 --- a/pkg/local_object_storage/shard/errors.go +++ b/pkg/local_object_storage/shard/errors.go @@ -3,7 +3,7 @@ package shard import ( "errors" - "github.com/nspcc-dev/neofs-node/pkg/core/object" + meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" ) @@ -28,5 +28,5 @@ func IsErrOutOfRange(err error) bool { // IsErrObjectExpired checks if an error returned by Shard corresponds to // expired object. func IsErrObjectExpired(err error) bool { - return errors.Is(err, object.ErrObjectIsExpired) + return errors.Is(err, meta.ErrObjectIsExpired) } diff --git a/pkg/local_object_storage/writecache/init.go b/pkg/local_object_storage/writecache/init.go index 175463f50..5cfa50434 100644 --- a/pkg/local_object_storage/writecache/init.go +++ b/pkg/local_object_storage/writecache/init.go @@ -3,7 +3,6 @@ package writecache import ( "errors" - "github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" @@ -67,7 +66,7 @@ func (c *cache) isFlushed(addr oid.Address) bool { mRes, err := c.metabase.Exists(existsPrm) if err != nil { - return errors.Is(err, object.ErrObjectIsExpired) || errors.As(err, new(apistatus.ObjectAlreadyRemoved)) + return errors.Is(err, meta.ErrObjectIsExpired) || errors.As(err, new(apistatus.ObjectAlreadyRemoved)) } if !mRes.Exists() {