From 2b81781c566f019038e45cf5eea13282f3a560a6 Mon Sep 17 00:00:00 2001 From: ila Date: Sun, 3 May 2026 09:38:56 +0900 Subject: [PATCH] Fixed an issue where only the first page of files (default 50) was added to the Aria2 queue when selecting a directory. - Implemented a pagination loop in fetchFolderStructure to recursively retrieve all files across all pages. - Replaced the hardcoded page size with getPagination().size to sync with the Admin "default_page_size" setting. - Ensures that all items in a directory and its sub-directories are correctly sent to Aria2 regardless of the total file count. --- src/hooks/useDownload.ts | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/hooks/useDownload.ts b/src/hooks/useDownload.ts index 0322143593..b2bdc3658e 100644 --- a/src/hooks/useDownload.ts +++ b/src/hooks/useDownload.ts @@ -3,6 +3,7 @@ import { local, password, selectedObjs as _selectedObjs } from "~/store" import { fsList, notify, pathBase, pathJoin } from "~/utils" import { getLinkByDirAndObj, useRouter, useT } from "~/hooks" import { useSelectedLink } from "~/hooks" +import { getPagination } from "~/store/settings" import { Obj } from "~/types" interface File { @@ -69,24 +70,35 @@ export const useDownload = () => { }, ] } else { - const resp = await fsList( - pathJoin(pathname(), pre, obj.name), - password(), - ) - if (resp.code !== 200) { - return resp.message - } const res: File[] = [] - for (const _obj of resp.data.content ?? []) { - const _res = await fetchFolderStructure( - pathJoin(pre, obj.name), - _obj, + let page = 1 + const perPage = getPagination().size + while (true) { + const resp = await fsList( + pathJoin(pathname(), pre, obj.name), + password(), + page, + perPage, ) - if (typeof _res === "string") { - return _res - } else { - res.push(..._res) + if (resp.code !== 200) { + return resp.message + } + const content = resp.data.content ?? [] + for (const _obj of content) { + const _res = await fetchFolderStructure( + pathJoin(pre, obj.name), + _obj, + ) + if (typeof _res === "string") { + return _res + } else { + res.push(..._res) + } + } + if (content.length < perPage) { + break } + page++ } return res }