metabase: Check parameter for CountAliveObjectsInBucket
#1414
1 changed files with 3 additions and 2 deletions
|
@ -452,10 +452,11 @@ func (db *DB) CountAliveObjectsInBucket(ctx context.Context, prm CountAliveObjec
|
|||
return 0, ErrDegradedMode
|
||||
}
|
||||
|
||||
cidRaw := prm.BucketName[1:bucketKeySize]
|
||||
if cidRaw == nil {
|
||||
if len(prm.BucketName) != bucketKeySize {
|
||||
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
cidRaw := prm.BucketName[1:bucketKeySize]
|
||||
var count uint64
|
||||
err := db.boltDB.View(func(tx *bbolt.Tx) error {
|
||||
bkt := tx.Bucket(prm.BucketName)
|
||||
|
|
Loading…
Reference in a new issue
if len(prm.BucketName) == 0
would be nicer, it prevents a possible panic which is not caught bynil
comparisonThanks, fixed.
BTW, it still can be less than the
bucketKeySize
Not for this PR: is there any reason we leak
BucketName
to the upper level?It seems enough to operate with some notion of
object type
andcontainer id
, both of which are already existing abstractions.Right, need to check for
bucketKeySize
. Updated.As for
BucketName
- no strong reason, just for quicker implementation and less compute.I'll update method signature - will use object type and container id.