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.
pull/3370/head
saschabuehrle 6 months ago
parent 006680c5df
commit 6c219120c7

@ -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))

Loading…
Cancel
Save