From c8ecf7d3067c4bd274a21a476ca08c7ba4d00a7c Mon Sep 17 00:00:00 2001 From: VirtualHotBar Date: Tue, 2 Jun 2026 07:25:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20#16=20=E6=94=AF=E6=8C=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/task/runner.ts | 6 +++-- src/page/task/add.tsx | 2 +- src/services/storage/TransferService.ts | 30 ++++++++++++++++++++----- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/controller/task/runner.ts b/src/controller/task/runner.ts index c16562f..d5bd5ff 100644 --- a/src/controller/task/runner.ts +++ b/src/controller/task/runner.ts @@ -9,8 +9,9 @@ async function runTask(task: TaskListItem): Promise { switch (t.taskType) { case 'copy': { + const copyFilterRules = t.parameters?.filterRules as string[] | undefined if (srcIsDir && targetIsDir) { - await copyDir(t.source.storageName, t.source.path, t.target.storageName, t.target.path) + await copyDir(t.source.storageName, t.source.path, t.target.storageName, t.target.path, copyFilterRules) } else if (!srcIsDir && !targetIsDir) { await copyFile(t.source.storageName, t.source.path, t.target.storageName, t.target.path, true) } else if (!srcIsDir && targetIsDir) { @@ -21,8 +22,9 @@ async function runTask(task: TaskListItem): Promise { break } case 'move': { + const moveFilterRules = t.parameters?.filterRules as string[] | undefined if (srcIsDir && targetIsDir) { - await moveDir(t.source.storageName, t.source.path, t.target.storageName, t.target.path) + await moveDir(t.source.storageName, t.source.path, t.target.storageName, t.target.path, undefined, moveFilterRules) } else if (!srcIsDir && targetIsDir) { await moveFile(t.source.storageName, t.source.path, t.target.storageName, t.target.path) } else if (!srcIsDir && !targetIsDir) { diff --git a/src/page/task/add.tsx b/src/page/task/add.tsx index 9bf253f..fd80b63 100644 --- a/src/page/task/add.tsx +++ b/src/page/task/add.tsx @@ -367,7 +367,7 @@ function AddTask_page() { )} - {(taskInfo.taskType === 'sync' || taskInfo.taskType === 'bisync') && ( + {taskInfo.taskType !== 'delete' && ( = { srcFs, dstFs, - }) + } + + // 添加过滤规则 + if (filterRules && filterRules.length > 0) { + params.filter = filterRules.join('\n') + } + + const success = await rclone_api_exec_async('/sync/copy', params) if (!success) { throw new Error(`Copy directory failed: ${srcFs} -> ${dstFs}`) } @@ -108,6 +117,7 @@ async function copyDir( * @param destStoragename - Destination storage name * @param destPath - Destination directory path * @param newNmae - New directory name (optional) + * @param filterRules - Optional array of rclone filter rules (e.g., ["+ *.jpg", "- *.tmp"]) * @throws Error if source or destination is invalid */ async function moveDir( @@ -115,7 +125,8 @@ async function moveDir( path: string, destStoragename: string, destPath: string, - newNmae?: string + newNmae?: string, + filterRules?: string[] ) { // 参数验证 if (!storageName || !destStoragename) { @@ -133,10 +144,17 @@ async function moveDir( throw new Error('Invalid source or destination path') } - const success = await rclone_api_exec_async('/sync/move', { + const params: Record = { srcFs, dstFs, - }) + } + + // 添加过滤规则 + if (filterRules && filterRules.length > 0) { + params.filter = filterRules.join('\n') + } + + const success = await rclone_api_exec_async('/sync/move', params) if (!success) { throw new Error(`Move directory failed: ${srcFs} -> ${dstFs}`) }