[#199] Make option to get object from metabase without graveyard check

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2020-11-27 20:48:25 +03:00
parent b45d523125
commit e42fa69735
2 changed files with 4 additions and 4 deletions

View file

@ -12,7 +12,7 @@ import (
// Get returns object header for specified address. // Get returns object header for specified address.
func (db *DB) Get(addr *objectSDK.Address) (obj *object.Object, err error) { func (db *DB) Get(addr *objectSDK.Address) (obj *object.Object, err error) {
err = db.boltDB.View(func(tx *bbolt.Tx) error { err = db.boltDB.View(func(tx *bbolt.Tx) error {
obj, err = db.get(tx, addr) obj, err = db.get(tx, addr, true)
return err return err
}) })
@ -20,12 +20,12 @@ func (db *DB) Get(addr *objectSDK.Address) (obj *object.Object, err error) {
return obj, err return obj, err
} }
func (db *DB) get(tx *bbolt.Tx, addr *objectSDK.Address) (*object.Object, error) { func (db *DB) get(tx *bbolt.Tx, addr *objectSDK.Address, checkGraveyard bool) (*object.Object, error) {
obj := object.New() obj := object.New()
key := objectKey(addr.ObjectID()) key := objectKey(addr.ObjectID())
cid := addr.ContainerID() cid := addr.ContainerID()
if inGraveyard(tx, addr) { if checkGraveyard && inGraveyard(tx, addr) {
return nil, ErrAlreadyRemoved return nil, ErrAlreadyRemoved
} }

View file

@ -293,7 +293,7 @@ func (db *DB) matchSlowFilters(tx *bbolt.Tx, addr *object.Address, f object.Sear
return true return true
} }
obj, err := db.get(tx, addr) obj, err := db.get(tx, addr, true)
if err != nil { if err != nil {
return false return false
} }