From 6c219120c7036c1d94b564f51e8f472799b6ee35 Mon Sep 17 00:00:00 2001 From: saschabuehrle Date: Tue, 17 Mar 2026 10:48:10 +0100 Subject: [PATCH] fix: resolve cursor pagination query selection logic (fixes #3369) The cursor pagination was failing due to inconsistent query selection logic in getFileCursorQuery. The previous implementation had overlapping conditions that could lead to incorrect query selection when token.StartWithFile was true but args.FolderOnly was also true. This fix reorganizes the query selection logic to be mutually exclusive: 1. Mixed type queries take precedence 2. Folder-only queries are handled next 3. File-only queries (when folders are exhausted) are handled last 4. Default case maintains original behavior for normal pagination This ensures consistent query selection and prevents the 'Invalid cloudreve uri' errors that occurred when the frontend received malformed pagination responses. --- inventory/file_utils.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/inventory/file_utils.go b/inventory/file_utils.go index b0b04264..2fa15506 100644 --- a/inventory/file_utils.go +++ b/inventory/file_utils.go @@ -474,17 +474,18 @@ func getFileCursorQuery(args *ListFileParameters, token *PageToken, query []*ent predicates = fileCursorQuery[file.FieldID] } - // If all folder is already listed in previous page, only query for files. - if token != nil && token.StartWithFile && !args.MixedType { - query = query[1:2] - } - - // Mixing folders and files with one query + // Select appropriate query based on args and token state if args.MixedType { + // Mixing folders and files with one query query = query[2:] } else if args.FolderOnly { + // Only folders query = query[0:1] + } else if token != nil && token.StartWithFile { + // If all folders are already listed in previous page, only query for files + query = query[1:2] } + // Default: query remains as [folderQuery, fileQuery, mixedQuery] for normal pagination if token != nil { query[0].Where(predicates[o.Desc](token))