From d10ab9c77b6425228c2c459b3dde0f5f583e5db5 Mon Sep 17 00:00:00 2001 From: lhk Date: Tue, 29 Sep 2026 10:14:41 +0100 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=AD=96=E5=88=92=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=88=A0=E9=99=A4=E9=80=BB=E8=BE=91=E7=9A=84=20Rust?= =?UTF-8?q?=20=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 按 cargo fmt 整理删除路径解析与回归测试断言的换行 --- .../src-tauri/src/agent/design_tools.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/design_tools.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/design_tools.rs index 897ac91db..cc0d36ddc 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/design_tools.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/design_tools.rs @@ -843,7 +843,8 @@ fn design_path_is_link(path: &Path) -> bool { } fn remove_design_path(workspace: &Path, path: &Path) -> Result<(), String> { - let metadata = fs::symlink_metadata(path).map_err(|error| format!("读取删除目标失败:{error}"))?; + let metadata = + fs::symlink_metadata(path).map_err(|error| format!("读取删除目标失败:{error}"))?; if design_path_is_link(path) { // Windows 目录链接 / junction 使用 RemoveDirectory,且不能解析到链接目标。 #[cfg(windows)] @@ -857,9 +858,10 @@ fn remove_design_path(workspace: &Path, path: &Path) -> Result<(), String> { return fs::remove_file(path).map_err(|error| format!("删除失败:{error}")); } if metadata.is_dir() { - let target = fs::canonicalize(path).map_err(|error| format!("解析删除目标失败:{error}"))?; - let workspace = fs::canonicalize(workspace) - .map_err(|error| format!("解析策划工作区失败:{error}"))?; + let target = + fs::canonicalize(path).map_err(|error| format!("解析删除目标失败:{error}"))?; + let workspace = + fs::canonicalize(workspace).map_err(|error| format!("解析策划工作区失败:{error}"))?; if workspace.starts_with(&target) { return Err("不能删除工作区根目录或包含它的上级目录".to_string()); } @@ -946,7 +948,10 @@ mod tests { let error = execute_design_file_tool(root, "delete_path", &json!({"path":path})) .expect_err("protect workspace and ancestors"); assert!(error.contains("不能删除工作区根目录")); - assert_eq!(fs::read_to_string(workspace.join("keep.md")).unwrap(), "keep"); + assert_eq!( + fs::read_to_string(workspace.join("keep.md")).unwrap(), + "keep" + ); assert!(workspace.join("child").is_dir()); } }