From 96705e965d7205962d701ebafdc8b132269bb466 Mon Sep 17 00:00:00 2001 From: imbytecat Date: Wed, 21 Jan 2026 23:44:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=80=A7=E6=A3=80=E6=9F=A5=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=A4=8D=E5=88=B6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加目录存在性检查功能并更新复制逻辑以使用该功能 --- apps/desktop/copy.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/apps/desktop/copy.ts b/apps/desktop/copy.ts index c7c54c6..6420088 100644 --- a/apps/desktop/copy.ts +++ b/apps/desktop/copy.ts @@ -159,6 +159,9 @@ class FileSystemService extends Context.Tag('FileSystemService')< readonly fileExists: ( filePath: string, ) => Effect.Effect + readonly dirExists: ( + dirPath: string, + ) => Effect.Effect readonly copyFile: ( source: string, target: string, @@ -193,6 +196,25 @@ class FileSystemService extends Context.Tag('FileSystemService')< }), }), + dirExists: (dirPath: string) => + Effect.tryPromise({ + try: async () => { + const { default: fs } = await import('node:fs/promises') + try { + const stat = await fs.stat(dirPath) + return stat.isDirectory() + } catch { + return false + } + }, + catch: (cause: unknown) => + new FileSystemError({ + operation: 'dirExists', + path: dirPath, + cause, + }), + }), + copyFile: (source: string, target: string) => Effect.tryPromise({ try: async () => { @@ -381,7 +403,7 @@ const program = Effect.gen(function* () { yield* Console.log('📦 开始复制二进制文件到 Tauri sidecar 目录...\n') // 1. 检查源目录 - const sourceExists = yield* fs.fileExists(config.sourceDir) + const sourceExists = yield* fs.dirExists(config.sourceDir) if (!sourceExists) { yield* Console.error(`❌ 源目录不存在: ${config.sourceDir}`) yield* Console.log(