Repository navigation
feat: 将书籍、分组、规则与书架进度迁入 SQLite - #13
Merged
Merged
Conversation
This was referenced Oct 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
解决的问题 / Problem
书籍、分组、规则与阅读进度原来分散保存在 JSON 文件中,书库查询及正文回写需要扫描或重写大文件。本 PR 将这些数据迁入 SQLite,并按补充要求将书架进度直接写入 books 元数据;备份导出 SQLite,书源继续导出 JSON。
Fixes #11
改动后的行为 / Resulting behavior
数据根共享
books.sqlite3:books 保存元信息(含封面和detail.progress),chapters 按章保存正文、章节头、指纹与图片引用,书签和段落注释分别存表。正文批次与派生数据同事务提交,删书同时移除进度并级联清理章节、书签和注释。书架 / 书源分组存入 groups,文本替换 / 分章规则存入 rules,逐项保留顺序与原字段;collections 区分空集合与缺失集合。其他偏好、阅读时长、书源、登录态、图片及 TTS 缓存沿用文件存储。
原 state command 与同步数据形状保持兼容。书架接口读取 books 中的进度视图,通过 JSON SQL 函数仅修改有变化的进度字段;初始化只补缺项,重置在后端执行。改书名 / 分组和整书保存保留进度,身份迁移同步更新进度 bookId 与规则引用。
旧目录 / 整书 JSON、全库书签及上述五类 state JSON 迁入数据库后留
.json.migrated备份;事务回执防止归档中断后重复导入覆盖新编辑。损坏旧数据保留原文件与重试,未完成迁移时拒绝不完整备份。新备份
readerx-backup/2的 ZIP 包含经VACUUM INTO生成的一致 SQLite 快照,分组、规则与进度只存在于该快照中;书源仍为book_sources/<id>.json,不导出 WAL / SHM / journal。凭据过滤和临时文件清理保持原语义。恢复先只读校验数据库版本、完整性、引用及逐行内容,再逐书、逐集合执行身份映射和合并 / 覆盖;不整库替换本机数据库,不导入旧设备的迁移回执。继续读取旧 JSON 备份和 v1 SQLite + state JSON 布局,进度合并保留 updatedAt 较新的记录。
更新存储、备份、同步文档与 readerx-data skill,补充真实 SQLite / ZIP、故障回滚及同步回归。
新增手动签名 arm64 release APK 工作流(只上传 artifact,不发布),复用现有四个 Android 签名 Secrets;校验实际签名与 arm64-v8a ABI,始终清理签名文件。
PR CI 仅执行 TypeScript 类型、i18n、模拟产物收集回归、Rust workspace / 测试目标代码检查和 Actions 语法检查,不执行生产构建、cargo build 或平台打包(cargo check 会编译依赖并运行构建脚本);Linux 数据回归仅手动触发。详见 CI 与构建。
验证 / Validation
actionlint、7 项node --test scripts/collect-artifacts.test.mjs、签名配置 Java Properties 特殊字符往返、git diff --check通过。本次 CI 改为仅检查后,本地 actionlint、类型、i18n、7 项产物回归与 diff 检查通过;Rust 代码检查使用cargo check --locked --workspace --all-targets,由 Linux CI 执行。手动 release 签名构建尚未触发。pnpm exec tsc --noEmit通过。pnpm run i18n:check通过(已有 42 条提示,无错误)。pnpm build通过。c95250d的 Linux CI 全部通过:book_store 35 项、书籍 ID 迁移 3 项、数据 ID 迁移 1 项、data_transfer 38 项、sync_bridge 26 项、readerx-sync 199 项、readerx-source 65 项(串行运行),共 367 项测试。git diff --check通过。新增回归覆盖旧 state 迁移与归档失败重试、集合事务回滚、进度 ensure / reset、整书和元信息补丁保留进度、ID 改写、v1 数据库升级 / 读取、快照后的本机编辑、两版备份恢复、异常集合 / 进度类型在导入前拒绝,以及同步故障恢复。数据与兼容性 / Data and compatibility
数据库
PRAGMA user_version=2,自动升级 v1 并保留原书籍数据;恢复接受 v1 和 v2 数据库。进度属于 books 元数据,不新增独立进度表。规则与分组按集合 key、顺序及 JSON 记录保存,兼容既有前端字段。备份格式为
readerx-backup/2,导入向后兼容readerx-backup/1,旧版 ReaderX 无法读取新格式数据库。线上同步协议和 command 数据形状不变;合并保留本机额外数据,覆盖先写后删,旧备份缺失注释仍清空该书注释。Rust 沿用 rusqlite + bundled SQLite 的同步存储入口。未更新版本或 CHANGELOG;Android / Windows 的实际构建及平台生命周期仍未验证。
提交前检查 / Checklist