Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

filer store: redis2 fix wrong pagination

Chris Lu2e76834e4da0
diff --git a/weed/filer/redis2/universal_redis_store.go b/weed/filer/redis2/universal_redis_store.go
index ecf68a9eee..f9798cf2f6 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)
}