Skip to content

fix(portable): 避免数据目录切换时丢失设置和代码片段 - #6771

Merged
t8y2 merged 1 commit into
t8y2:mainfrom
zipg:codex/fix-windows-portable-persistence
Aug 31, 2026
Merged

fix(portable): 避免数据目录切换时丢失设置和代码片段#6771
t8y2 merged 1 commit into
t8y2:mainfrom
zipg:codex/fix-windows-portable-persistence

Conversation

@zipg

@zipg zipg commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

问题

Windows 便携版的数据目录发生切换时,启动兜底迁移仅将连接、历史和 SQL 库等表识别为用户数据。app_settingsapp_state 未被识别,导致仅保存了设置或自定义代码片段的数据库被误判为空,启动后表现为恢复默认。

修复

  • 将设置、编辑器状态、代码片段及其他持久化用户表纳入数据存在性判断
  • 允许仅包含设置和代码片段的源数据库参与兜底迁移
  • 目标数据库已有设置时保持不覆盖
  • 修正“空目标数据库”测试,使其只包含初始化 schema

验证

  • cargo test -p dbx-core import_user_data_db --lib:7 passed
  • cargo test -p dbx-core --lib:5164 passed, 0 failed, 59 ignored(变基前全量验证)
  • cargo test --manifest-path src-tauri/Cargo.toml data_dir --lib:9 passed(变基前验证)
  • cargo fmt --all -- --check
  • git diff --check

待验证

当前开发环境为 macOS,尚未完成 Windows 便携版实际退出、重启及数据目录切换验证,因此先提交为草稿 PR。

@github-actions github-actions Bot added area/core Shared DBX core runtime bug Something isn't working labels Aug 20, 2026
@zipg
zipg force-pushed the codex/fix-windows-portable-persistence branch from c212e8b to bb0f290 Compare August 30, 2026 11:15
@github-actions github-actions Bot added the area/docs Documentation site or repository documentation label Aug 30, 2026
@zipg
zipg force-pushed the codex/fix-windows-portable-persistence branch from bb0f290 to 016c285 Compare August 30, 2026 11:23
@github-actions github-actions Bot removed the area/docs Documentation site or repository documentation label Aug 30, 2026
@zipg
zipg marked this pull request as ready for review August 30, 2026 15:14

@t8y2 t8y2 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已核对,修复方向和实现都正确,无阻塞意见。

根因确认:sqlite_db_has_user_data 同时用于源库非空与目标库已有数据判断,而原 USER_DATA_TABLES 漏掉了 9 张持久化用户表——只保存过设置或代码片段的源库会被判为空而跳过迁移,只含设置的目标库会被当作空库覆盖。加入后两个方向同时修复。完整性核对:对照全部建表语句,未纳入的仅剩两张缓存表,排除正确。

作用域核对:仅便携模式数据目录切换时触发,不影响常规安装和非 Windows;导入在 Storage::open 之前执行,无误判风险;旧目录数据是拷贝不是删除。

非阻塞建议:USER_DATA_TABLES 是手工清单,今后新增持久化表漏加会复现同类 bug,建议后续补一个从 sqlite_master 导出全部表并断言覆盖的守护测试。

@t8y2
t8y2 merged commit 2779a43 into t8y2:main Aug 31, 2026
15 checks passed
@t8y2

t8y2 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution! Merged in 2779a43, will be released in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Shared DBX core runtime bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants