feat: 支持修改启动器数据目录位置(issue #43) - #44
Conversation
…sue dsh-plugins#43) - migrate.rs: bootstrap resolution chain (env DSH_LAUNCHER_DATA_HOME > pointer file data-home.txt > default app data dir), one-shot migration before the log handle opens: copy config/versions/homes/logs/.pnpm-store/ tools/icons/bin -> verify -> switch -> snapshot old dir as .old-<ts>. Failure rolls back to the default dir and drops the pointer. - AppState gains data_dir_source + data_dir_notice; commands pick_data_dir (blocking folder dialog), commit_data_dir (validate + write pointer), get_data_dir_source (path + source + fallback notice). - lib.rs setup calls migrate::bootstrap before applog::init and ensure_local_node_on_path, so logs/ and tools/ move cleanly. - 4 unit tests for paths_equal/dir_is_empty/copy_tree/tree_stats.
…sh-plugins#43) - Settings.vue: data-dir card gains a 'Change location' button that opens the folder dialog (pick_data_dir), validates + writes the pending pointer file (commit_data_dir), then shows a restart hint modal; the card also displays the current source ('env' / 'pointer' / 'default') and surfaces the startup fallback notice as a toast. - api/index.ts: pickDataDir / commitDataDir / getDataDirSource wired with browser-preview mock branches; types.ts adds DataDirInfo. - i18n: zh-CN + en-US keys for moveTo/restartHint/migrating/migratedToast/ source*/rollback/confirmMove.
…cords (issue dsh-plugins#43) - copy_tree handles file sources (no create_dir_all on files) — fixes os error 267 when migrating config.json. - New tests: migrate_data_dir_copies_and_clears_flag, migrate_data_dir_rejects_non_empty_target, migrate_data_dir_failure_removes_partial_target. - Full suite: 119 passed; tauri build produced exe/msi/nsis bundles.
请求修改(request changes)自举解析链、指针文件、启动期迁移(早于 阻塞项 1:
|
- 迁移复制完成后将 config.json 中落在旧目录下的 versions[].dir / homes[].path 重写到新目录;已迁移分支每次启动幂等自愈 - 默认目录只剩指针文件时不再快照,修复每次启动累积 .old-* 目录 - 补 30 天快照保留期的实际裁剪(prune_old_snapshots) - 新增 7 个测试:路径重写/幂等/坏配置容错/指针忽略/快照行为
|
审查后修复并合入(dfcd5e3)。 合入前由我修复的阻断问题:
新增 7 个测试(路径重写/幂等/坏配置容错/指针忽略/快照行为/保留期裁剪)。本地门禁:fmt ✓ / clippy -D warnings ✓ / cargo test 126 ✓;CI Quality 三平台 ✓。 遗留(非阻断,后续 issue 跟进):copy_tree 解引用 junction 导致迁移慢且体积膨胀(实测 15400 个 reparse point / 11284 份冗余拷贝,但无循环,安全)。 |
概述
支持修改启动器数据目录位置(issue #43)。设置页「数据目录」卡片新增「更改位置」入口,重启后自动把现有数据(配置、版本、HOME 目录、日志、npm 缓存、托管 node 等)迁移到新位置;支持
DSH_LAUNCHER_DATA_HOME环境变量覆盖;任一步失败自动回滚,不损坏原数据。变更内容
自举解析链(migrate.rs)
优先级:
DSH_LAUNCHER_DATA_HOME环境变量 > 指针文件<默认app_data_dir>\data-home.txt> 默认目录。迁移状态机
迁移在重启后的启动阶段执行(日志文件句柄打开之前),流程:
MIGRATION_IN_PROGRESS标记(power-failure/杀进程安全,中断后下次启动清理半成品重来)config.json / versions/ / homes/ / logs/ / .pnpm-store/ / tools/ / icons/ / bin/(纯 std::fs 递归,不新增依赖)<dir>.old-<ts>,不直接删除(30 天恢复窗口)新命令
pick_data_dir— 打开目录选择器(tauri-plugin-dialog)commit_data_dir— 校验新目录(非空 / 是否已存在 / 可写)并写入指针文件,不移动文件get_data_dir_source— 返回当前路径 + 来源(env / pointer / default)+ 兜底提示 noticeUI(i18n 双语)
设置页数据目录卡片:来源标识、迁移失败 toast、更改位置按钮 + 重启确认 Modal。
验证
cargo check零告警npx tsc --noEmit零错误pnpm build通过tauri build产出 exe / msi / nsis 三产物DSH_LAUNCHER_DATA_HOME指向临时目录启动,日志确认数据目录解析到该位置附加
docs/ISSUE43_TASK_TREE.md:任务执行记录(6 阶段逐轮回填)。