aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-10-27 23:46:25 -0700
committerChris Lu <chris.lu@gmail.com>2021-10-27 23:46:25 -0700
commit2e76834e4da0ae430f68befa42a82a497e9521ff (patch)
tree4e3768c5615b55b224876814e0f03ba28bfd5f21
parent54b6e0f3fd8a83dcf7aa79b069ab7fd8e45ecaf6 (diff)
downloadseaweedfs-2e76834e4da0ae430f68befa42a82a497e9521ff.tar.xz
seaweedfs-2e76834e4da0ae430f68befa42a82a497e9521ff.zip
filer store: redis2 fix wrong pagination
-rw-r--r--weed/filer/redis2/universal_redis_store.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/weed/filer/redis2/universal_redis_store.go b/weed/filer/redis2/universal_redis_store.go
index ecf68a9ee..f9798cf2f 100644
--- a/weed/filer/redis2/universal_redis_store.go
+++ b/weed/filer/redis2/universal_redis_store.go
@@ -133,7 +133,10 @@ func (store *UniversalRedis2Store) DeleteFolderChildren(ctx context.Context, ful
return nil
}
- members, err := store.Client.ZRange(ctx, genDirectoryListKey(string(fullpath)), 0, -1).Result()
+ members, err := store.Client.ZRangeByLex(ctx, genDirectoryListKey(string(fullpath)), &redis.ZRangeBy{
+ Min: "-",
+ Max: "+",
+ }).Result()
if err != nil {
return fmt.Errorf("DeleteFolderChildren %s : %v", fullpath, err)
}
@@ -158,14 +161,22 @@ func (store *UniversalRedis2Store) ListDirectoryPrefixedEntries(ctx context.Cont
func (store *UniversalRedis2Store) ListDirectoryEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int64, eachEntryFunc filer.ListEachEntryFunc) (lastFileName string, err error) {
dirListKey := genDirectoryListKey(string(dirPath))
- start := int64(0)
+
+ min := "-"
if startFileName != "" {
- start, _ = store.Client.ZRank(ctx, dirListKey, startFileName).Result()
- if !includeStartFile {
- start++
+ if includeStartFile {
+ min = "[" + startFileName
+ } else {
+ min = "(" + startFileName
}
}
- members, err := store.Client.ZRange(ctx, dirListKey, start, start+int64(limit)-1).Result()
+
+ members, err := store.Client.ZRangeByLex(ctx, dirListKey, &redis.ZRangeBy{
+ Min: min,
+ Max: "+",
+ Offset: 0,
+ Count: limit,
+ }).Result()
if err != nil {
return lastFileName, fmt.Errorf("list %s : %v", dirPath, err)
}