[#199] Split IsSmall check in metabase
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
5bfae833fe
commit
b45d523125
1 changed files with 13 additions and 8 deletions
|
@ -12,17 +12,22 @@ import (
|
|||
// indexed in metabase.
|
||||
func (db *DB) IsSmall(addr *objectSDK.Address) (id *blobovnicza.ID, err error) {
|
||||
err = db.boltDB.View(func(tx *bbolt.Tx) error {
|
||||
// if graveyard is empty, then check if object exists in primary bucket
|
||||
smallBucket := tx.Bucket(smallBucketName(addr.ContainerID()))
|
||||
if smallBucket == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
blobovniczaID := smallBucket.Get(objectKey(addr.ObjectID()))
|
||||
id = blobovnicza.NewIDFromBytes(blobovniczaID)
|
||||
id, err = db.isSmall(tx, addr)
|
||||
|
||||
return err
|
||||
})
|
||||
|
||||
return id, err
|
||||
}
|
||||
|
||||
func (db *DB) isSmall(tx *bbolt.Tx, addr *objectSDK.Address) (*blobovnicza.ID, error) {
|
||||
smallBucket := tx.Bucket(smallBucketName(addr.ContainerID()))
|
||||
if smallBucket == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
blobovniczaID := smallBucket.Get(objectKey(addr.ObjectID()))
|
||||
id := blobovnicza.NewIDFromBytes(blobovniczaID)
|
||||
|
||||
return id, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue