From afb45fccc0b70bef2b4486f323a8f27043ad4feb Mon Sep 17 00:00:00 2001 From: mtvpls Date: Tue, 23 Dec 2025 00:55:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dopenlist=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E6=97=B6=E4=B8=8D=E5=88=86=E9=A1=B5=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/openlist/refresh/route.ts | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/app/api/openlist/refresh/route.ts b/src/app/api/openlist/refresh/route.ts index e728858..a7acad3 100644 --- a/src/app/api/openlist/refresh/route.ts +++ b/src/app/api/openlist/refresh/route.ts @@ -118,14 +118,31 @@ async function performScan( }; // 2. 列出根目录下的所有文件夹(强制刷新 OpenList 缓存) - const listResponse = await client.listDirectory(rootPath, 1, 100, true); + // 循环获取所有页的数据 + const folders: any[] = []; + let currentPage = 1; + const pageSize = 100; + let total = 0; - if (listResponse.code !== 200) { - throw new Error('OpenList 列表获取失败'); + while (true) { + const listResponse = await client.listDirectory(rootPath, currentPage, pageSize, true); + + if (listResponse.code !== 200) { + throw new Error('OpenList 列表获取失败'); + } + + total = listResponse.data.total; + const pageFolders = listResponse.data.content.filter((item) => item.is_dir); + folders.push(...pageFolders); + + // 如果已经获取了所有数据,退出循环 + if (folders.length >= total) { + break; + } + + currentPage++; } - const folders = listResponse.data.content.filter((item) => item.is_dir); - // 更新任务进度 updateScanTaskProgress(taskId, 0, folders.length);