Skip to content

fix(data): migrate legacy Windows data directory on upgrade - #273

Merged
Suyunmeng merged 4 commits into
mainfrom
fix/data/issue-251-migrate-legacy-data
Nov 1, 2026
Merged

Suyunmeng merged 4 commits into
mainfrom
fix/data/issue-251-migrate-legacy-data

Conversation

@Suyunmeng

Copy link
Copy Markdown
Contributor

Summary / 摘要

Since v0.8.0 (#108), the Windows data directory moved from the install directory to %APPDATA%\OpenList Desktop, but no migration was added. After upgrading from v0.7.0, the app creates a fresh settings.json and OpenList Core starts with an empty data directory, so previously configured storages disappear.

自 v0.8.0(#108)起,Windows 的数据目录从安装目录改到了 %APPDATA%\OpenList Desktop,但没有做迁移。从 v0.7.0 升级后,程序会新建默认的 settings.json,OpenList Core 使用空的数据目录启动,原先配置的存储因此消失。

  • On first launch, copy settings.json, rclone.conf and the default data directory from the install directory to %APPDATA%\OpenList Desktop. The originals are kept in place as a backup.

  • OpenList Core stores absolute paths in config.json and does not re-derive them from --data, so database.db_file, temp_dir, bleve_dir and log.name under the old data directory are rewritten to the new location. Custom paths outside it are left unchanged.

  • The migration runs only when the per-user settings.json does not exist yet and the install directory has one. Existing files in the new location are never overwritten. If copying data fails, the partial copy is removed so the next launch retries. A failure is logged as a warning and does not block startup.

  • Windows only. Users who already launched v0.8.0+ (and therefore already have a per-user settings.json) are not migrated automatically.

  • 首次启动时,将安装目录中的 settings.json、rclone.conf 和默认 data 目录复制到 %APPDATA%\OpenList Desktop,原文件保留作为备份。

  • OpenList Core 在 config.json 中保存的是绝对路径,且不会根据 --data 重新计算,因此会把位于旧数据目录下的 database.db_file、temp_dir、bleve_dir、log.name 改写到新位置,旧数据目录之外的自定义路径保持不变。

  • 仅当用户目录下还没有 settings.json、而安装目录中存在时才会迁移,不会覆盖新位置已有的文件。复制 data 失败时会删除不完整的副本,下次启动重试。迁移失败只记录警告,不阻断启动。

  • 仅针对 Windows。已经启动过 v0.8.0 及以上版本(用户目录下已有 settings.json)的用户不会被自动迁移。

  • This PR has breaking changes.
    / 此 PR 包含破坏性变更。

  • This PR changes public API, config, storage format, or migration behavior.
    / 此 PR 修改了公开 API、配置、存储格式或迁移行为。

  • This PR requires corresponding changes in related repositories.
    / 此 PR 需要关联仓库同步修改。

Related Issues / 关联 Issue

Fixes #251

Testing / 测试

  • rustfmt --check --edition 2024 on the changed files with the repository rustfmt.toml: passed.
  • cargo check / cargo clippy: not run. The local toolchains could not build (GNU target is missing dlltool.exe, MSVC target is missing the C++ build tools). Relying on CI for compile and clippy checks.
  • Manual test / 手动测试: not yet performed. An upgrade from v0.7.0 to this build on Windows with at least one configured storage still needs to be verified.

Checklist / 检查清单

  • I have read CONTRIBUTING.
    / 我已阅读 CONTRIBUTING。
  • I confirm this contribution follows the repository license, contribution policy, and code of conduct.
    / 我确认此贡献符合仓库许可证、贡献规范和行为准则。
  • I have formatted the changed code with gofmt, go fmt, or prettier where applicable.
    / 我已按适用情况使用 gofmt、go fmt 或 prettier 格式化变更代码。
  • I have requested review from relevant maintainers or code owners where applicable.
    / 我已在适用情况下请求相关维护者或代码所有者审查。

AI Disclosure / AI 使用声明

  • This PR includes AI-assisted content.
    / 此 PR 包含 AI 辅助内容。

Tools used / 使用工具:

  • ChatGPT
  • Codex
  • GitHub Copilot
  • Claude
  • Gemini
  • Other (please specify) / 其他(请注明): Lunelle ( Experimental AI )

Usage scope / 使用范围:

  • Code generation / 代码生成

  • Refactoring / 重构

  • Documentation / 文档

  • Tests / 测试

  • Translation / 翻译

  • Review assistance / 审查辅助

  • I have reviewed and validated all AI-assisted content included in this PR.
    / 我已审核并验证此 PR 中的所有 AI 辅助内容。

  • I have ensured that all AI-assisted commits include Co-Authored-By attribution.
    / 我已确保所有 AI 辅助提交都包含 Co-Authored-By 归属信息。

  • I can reproduce all AI-assisted content included in this PR without any AI tools.
    / 我可以在没有任何 AI 工具的情况下重现此 PR 中包含的所有 AI 辅助内容。

Suyunmeng and others added 4 commits November 1, 2026 14:49
- Copy `settings.json`, `rclone.conf` and the default `data` directory from the install directory
  to `%APPDATA%\OpenList Desktop` on first launch, keeping the originals as backup
- Rewrite the absolute `db_file`, `temp_dir`, `bleve_dir` and `log.name` paths in the copied
  core `config.json` so OpenList Core uses the migrated files
- Skip the migration when the per-user `settings.json` already exists, and log a warning
  instead of blocking startup on failure

Fixes #251

Co-authored-by: LunelleEverdawn <lunelle+suyunmeng@oplist.org>
- Pin the `rust-check` and `build-test` jobs to `nightly-2026-10-31` (rustc 92b5b8c87), the last
  nightly that passed CI
- Avoid the `nightly-2026-11-01` regression that fails to compile `zbus` with E0391 on Linux and
  newly denies `clippy::new_instead_of_clear` in existing code

Co-authored-by: LunelleEverdawn <lunelle+suyunmeng@oplist.org>
- Replace the floating `nightly` toolchain with `1.99.1` in the lint, build test and release
  workflows, so a daily nightly update can no longer break CI or release builds
- Drop the temporary `nightly-2026-10-31` pin in the lint workflow

Co-authored-by: LunelleEverdawn <lunelle+suyunmeng@oplist.org>
- Use `dtolnay/rust-toolchain@stable` instead of the pinned `1.99.1` in the lint, build test and
  release workflows, so CI and release builds follow the latest stable Rust release

Co-authored-by: LunelleEverdawn <lunelle+suyunmeng@oplist.org>
@Suyunmeng
Suyunmeng merged commit bc3389c into main Nov 1, 2026
9 checks passed
@Suyunmeng
Suyunmeng deleted the fix/data/issue-251-migrate-legacy-data branch November 1, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows 从 v0.7.0 升级到 v0.9.1 后未保留原有数据目录,导致已配置存储消失

1 participant