mirror of https://github.com/jackwener/wx-cli.git
DbCache 之前只要 .db 或 .db-wal 任一 mtime 变就 full_decrypt。WeChat 在写消息
时会持续 append WAL(无 checkpoint 时),导致每次 attachments/extract 请求都
重新解密 1.8GB 的 message_0.db(实测 ~120s/次)。
改成三种 hit 路径:
1. db_mt + wal_mt 都不变 → 直接返回 cached path
2. db_mt 不变、wal_mt 变了 → 在 cached 产物上**再 apply 一次 WAL**
(apply_wal 是幂等的:旧帧 redo 同样的 page 写入,新帧追加生效)
3. db_mt 变了 → 全量解密 + apply WAL(旧路径)
效果:典型 WAL(< 10MB)从 ~120s 压到 < 1s;100MB 大 WAL 也只在 ~7s。
SQLite 不会自发"主库不变 + WAL 清空",所以 path 2 的边角不需要特殊处理。
测试覆盖三条路径:
- exact_mtime_hit_skips_decrypt
- wal_only_change_uses_incremental_path
- db_mtime_change_triggers_full_decrypt
区分手段:cached file 大小是否被 full_decrypt 重写到 PAGE_SZ 倍数。
|
||
|---|---|---|
| .. | ||
| attachment | ||
| cli | ||
| crypto | ||
| daemon | ||
| scanner | ||
| config.rs | ||
| ipc.rs | ||
| main.rs | ||