From b45d52312533a1f55391efb9a06c1a534d74387e Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Fri, 27 Nov 2020 20:47:58 +0300 Subject: [PATCH] [#199] Split IsSmall check in metabase Signed-off-by: Alex Vanin --- pkg/local_object_storage/metabase/v2/small.go | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pkg/local_object_storage/metabase/v2/small.go b/pkg/local_object_storage/metabase/v2/small.go index 0414138d58..b071581995 100644 --- a/pkg/local_object_storage/metabase/v2/small.go +++ b/pkg/local_object_storage/metabase/v2/small.go @@ -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 +}