( storageName: string, path: string, destStoragename: string, destPath: string )
| 412 | |
| 413 | //copyDir |
| 414 | async function copyDir( |
| 415 | storageName: string, |
| 416 | path: string, |
| 417 | destStoragename: string, |
| 418 | destPath: string |
| 419 | ) { |
| 420 | // 参数验证 |
| 421 | if (!storageName || !destStoragename) { |
| 422 | throw new Error('Source or destination storage name is empty') |
| 423 | } |
| 424 | if (!path) { |
| 425 | throw new Error('Source path is empty') |
| 426 | } |
| 427 | |
| 428 | const srcFs = convertStoragePath(storageName, path, true) |
| 429 | const dstFs = convertStoragePath(destStoragename, destPath, true) + getFileName(path) |
| 430 | |
| 431 | if (!srcFs || !dstFs) { |
| 432 | throw new Error('Invalid source or destination path') |
| 433 | } |
| 434 | |
| 435 | const success = await rclone_api_exec_async('/sync/copy', { |
| 436 | srcFs, |
| 437 | dstFs, |
| 438 | }) |
| 439 | if (!success) { |
| 440 | throw new Error(`Copy directory failed: ${srcFs} -> ${dstFs}`) |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | async function moveDir( |
| 445 | storageName: string, |
no test coverage detected