mirror of
https://github.com/jackwener/wx-cli.git
synced 2026-10-08 16:45:45 +00:00
fix: 深度 review 修复 10 个 bug/问题
Critical & High: - daemon 日志:启动时将 stdout/stderr 重定向到 ~/.wx-cli/daemon.log 而非 /dev/null,使 wx daemon logs 真正可用 - q_history 找不到聊天时改为 bail! 而非 ok:true+error 字段, 避免 CLI 静默返回空输出 - init 写 config.json 默认路径改为 ~/.wx-cli/config.json, 避免写入系统 bin 目录(/usr/local/bin/config.json) - LIKE 通配符:搜索关键词中的 %/_/\ 现在正确转义 - WAL 路径:改用 OsString.push 拼接 "-wal" 后缀, 避免 display() 在非 UTF-8 路径上失效 - cmd_stop:检查 kill() 返回值,ESRCH 时给出明确提示 Performance & Code quality: - full_decrypt:改为流式逐页读写,峰值内存从 2×文件大小降为 O(1) - Regex:msg_table_re() 用 OnceLock 静态编译,避免热路径重复编译 - mtime_nanos:消除 daemon/mod.rs 与 cache.rs 的重复定义 - use super::super::cli::transport → use super::transport - 删除未使用的 save_config、Request::to_json_line 死代码
This commit is contained in:
@@ -55,21 +55,6 @@ pub fn load_config() -> Result<Config> {
|
||||
})
|
||||
}
|
||||
|
||||
/// 保存配置到文件
|
||||
pub fn save_config(config: &Config) -> Result<()> {
|
||||
let config_path = find_config_file().unwrap_or_else(|_| {
|
||||
std::env::current_exe()
|
||||
.unwrap_or_default()
|
||||
.parent()
|
||||
.unwrap_or(Path::new("."))
|
||||
.join("config.json")
|
||||
});
|
||||
let content = serde_json::to_string_pretty(config)?;
|
||||
std::fs::write(&config_path, content)
|
||||
.with_context(|| format!("写入 config.json 失败: {}", config_path.display()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn find_config_file() -> Result<PathBuf> {
|
||||
// 1. 优先查找可执行文件同目录
|
||||
if let Ok(exe) = std::env::current_exe() {
|
||||
|
||||
Reference in New Issue
Block a user