[#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>
remotes/fyrchik/fix-grpc-timeout-backup
Pavel Karpy 2022-08-04 14:59:30 +03:00 committed by Pavel Karpy
parent 156ba85326
commit a5da665e69
1 changed files with 6 additions and 0 deletions

View File

@ -222,6 +222,12 @@ func stringCommonPrefixMatcherBucket(b *bbolt.Bucket, fKey string, fVal string,
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()
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]) {