修复: 文件日志 + G1 日志增强 + 清理死代码

- 文件日志: tracing-subscriber + tracing-appender 写入 %TEMP%/devflow-trace.log
- G1 日志: 增加 first_goal 字段显示首条目标内容
- 清理: 删 workspace_root_str / data_dir_path 死代码
- 标注: default_with_root 加 cfg_attr 抑制 non-test 编译警告
This commit is contained in:
2026-06-27 23:27:31 +08:00
parent 5c539fe764
commit 7cd833b1e5
6 changed files with 48 additions and 29 deletions

View File

@@ -463,9 +463,9 @@ impl AllowedDirs {
pub const SETTINGS_KEY: &'static str = "allowed_dirs";
/// 空白名单(方案①弱化 workspace_root:不再编译期硬塞开发机 CARGO_MANIFEST_DIR)。
/// 分发后该路径指向编译机不存在的目录,硬塞反成脏白名单;用户首次访问任意目录
/// 走弹窗三档授权(once/session/always),对齐产品定位(不预设源码目录)。仅作 init
/// 占位(reload_allowed_dirs 从 KV 覆盖)+ 测试构造基线。
/// 分发后该路径指向编译机不存在的目录,硬塞反成脏白名单
/// 当前仅测试使用,生产环境由 reload_allowed_dirs 覆盖。
#[cfg_attr(not(test), allow(dead_code))]
pub fn default_with_root() -> Self {
Self { persistent: HashSet::new(), session: HashSet::new(), once: HashSet::new() }
}
@@ -668,14 +668,6 @@ fn workspace_root_path() -> PathBuf {
.unwrap_or_else(|| PathBuf::from("."))
}
/// 应用数据目录(运行期确定,跨平台)。
/// 不依赖编译期常量,打包分发后仍有效。
/// 用于 DevFlow 自身数据存储(.trash / logs 等),非用户项目目录。
/// 取 AppState.data_dir,不持 state 时回退 workspace_root_path()(开发期兼容)。
pub fn data_dir_path(state: &AppState) -> &Path {
&state.data_dir
}
impl AppState {
/// 初始化应用状态:打开(或创建)数据库并执行迁移,构建各 Repo 与节点注册表
pub async fn init(db_path: &Path, data_dir: PathBuf) -> Result<Self> {