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()); } }