From c7e7431fd367117590930cc1948aa9a25da60d7a Mon Sep 17 00:00:00 2001 From: qieqieplus Date: Thu, 7 Jan 2021 17:07:56 +0800 Subject: [PATCH] fix seek lastkey may reach EOF --- weed/filer/rocksdb/rocksdb_store.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/weed/filer/rocksdb/rocksdb_store.go b/weed/filer/rocksdb/rocksdb_store.go index 9e058a96d..2d5501637 100644 --- a/weed/filer/rocksdb/rocksdb_store.go +++ b/weed/filer/rocksdb/rocksdb_store.go @@ -182,17 +182,9 @@ func enumerate(iter *gorocksdb.Iterator, prefix, lastKey []byte, includeLastKey } else { iter.Seek(lastKey) - if !includeLastKey { - key := iter.Key().Data() - - if !bytes.HasPrefix(key, prefix) { - return nil - } - - if bytes.Equal(key, lastKey) { - iter.Next() - } - + if iter.Valid() && !includeLastKey && + bytes.Equal(iter.Key().Data(), lastKey) { + iter.Next() } } @@ -250,10 +242,6 @@ func (store *RocksDBStore) ListDirectoryPrefixedEntries(ctx context.Context, ful if fileName == "" { return true } - limit-- - if limit < 0 { - return false - } entry := &filer.Entry{ FullPath: weed_util.NewFullPath(string(fullpath), fileName), }