[#1656] meta: Fix MatchCommonPrefix operation

Return all the objects on the empty common prefix search without search
optimizations that breaks boltDB logic.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-08-04 14:59:30 +03:00 committed by Pavel Karpy
parent 156ba85326
commit a5da665e69

View file

@ -222,6 +222,12 @@ func stringCommonPrefixMatcherBucket(b *bbolt.Bucket, fKey string, fVal string,
prefix = val[:len(val)-1] prefix = val[:len(val)-1]
} }
if len(val) == 0 {
// empty common prefix, all the objects
// satisfy that filter
return b.ForEach(f)
}
c := b.Cursor() c := b.Cursor()
for k, v := c.Seek(val); bytes.HasPrefix(k, prefix); k, v = c.Next() { for k, v := c.Seek(val); bytes.HasPrefix(k, prefix); k, v = c.Next() {
if checkLast && (len(k) == len(prefix) || k[len(prefix)]>>4 != val[len(val)-1]) { if checkLast && (len(k) == len(prefix) || k[len(prefix)]>>4 != val[len(val)-1]) {