DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(worktree): 删除 key 必须恰好两段,拒绝多余段与结尾斜杠
hairyf63ec658d23bb
diff --git a/packages/dsh-tauri-worktree/src/host/service/worktree.test.ts b/packages/dsh-tauri-worktree/src/host/service/worktree.test.tsindex 8f38075b..e39e45e4 100644--- a/packages/dsh-tauri-worktree/src/host/service/worktree.test.ts+++ b/packages/dsh-tauri-worktree/src/host/service/worktree.test.ts@@ -318,6 +318,20 @@ describe('worktree.discard', () => {expect(existsSync(join(victim, 'keep.txt'))).toBe(true)})+ it('未绑定的 key 段数不合法(多余段 / 结尾斜杠)时被拒绝', async () => {+ const hash = 'ffffffffffff'+ const path = worktreePath(hash, 'repo')+ mkdirSync(path, { recursive: true })+ writeFileSync(join(path, 'keep.txt'), 'keep\n')++ const surplus = await worktree.discard('surplus-session', `${hash}/repo/extra`)+ const trailing = await worktree.discard('trailing-session', `${hash}/repo/`)++ expect(surplus.ok).toBe(false)+ expect(trailing.ok).toBe(false)+ expect(existsSync(join(path, 'keep.txt'))).toBe(true)+ })+it('无绑定且路径已消失时幂等成功且不产生任务', async () => {const repository = createRepository()const sessionId = 'no-binding-session'diff --git a/packages/dsh-tauri-worktree/src/host/utils/paths.ts b/packages/dsh-tauri-worktree/src/host/utils/paths.tsindex a05527d9..141c2231 100644--- a/packages/dsh-tauri-worktree/src/host/utils/paths.ts+++ b/packages/dsh-tauri-worktree/src/host/utils/paths.ts@@ -20,6 +20,9 @@ export function worktreeTrashPath(hash: string, dirname: string): string {}export function parseWorktreeKey(key: string): { hash: string, dirname: string } | null {- const [hash, dirname] = String(key ?? '').split('/')+ const segments = String(key ?? '').split('/')+ if (segments.length !== 2)+ return null+ const [hash, dirname] = segmentsreturn hash && dirname ? { hash, dirname } : null}