From 84fd6c96bd5e3909a0acf8ac05a24e5853ca569e Mon Sep 17 00:00:00 2001 From: Belugary <53219544+Belugary@users.noreply.github.com> Date: Tue, 12 May 2026 21:02:49 +0800 Subject: [PATCH] fix(config): correct macOS db_dir template to sandbox container path (#86) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem On macOS, the default `db_dir` template in `config.py` (line 20) points to `~/Documents/xwechat_files/your_wxid/db_storage`, but WeChat 4.x on macOS stores data inside the app sandbox container at `~/Library/Containers/com.tencent.xinWeChat/Data/Documents/xwechat_files//db_storage`. `_auto_detect_db_dir_macos()` (config.py:166) handles the common case, but when auto-detect fails — fresh install with no scan results yet, permission issues, atypical install location — the template fallback is what the user sees in their generated `config.json`. Today that fallback is a Linux-style path that does not exist on macOS, so the user has to manually correct it before the first run can succeed. ## Fix Update the darwin branch of `_DEFAULT_TEMPLATE_DIR` to the actual sandbox container path. `your_wxid` remains a placeholder. Linux and Windows templates are unchanged. ## Tests Existing `tests/` pass (168 / 168). The change only affects a module-level constant; no behavior change for users whose auto-detect already succeeds. ## Scope 3 lines in `config.py`. No public API change, no schema change, no dependency change. --- config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index ff59b7b..10290fd 100644 --- a/config.py +++ b/config.py @@ -17,7 +17,9 @@ if _SYSTEM == "linux": _DEFAULT_PROCESS = "wechat" elif _SYSTEM == "darwin": # macOS 使用独立的 C 扫描器 (find_all_keys_macos.c),此处仅提供 config 默认值 - _DEFAULT_TEMPLATE_DIR = os.path.expanduser("~/Documents/xwechat_files/your_wxid/db_storage") + _DEFAULT_TEMPLATE_DIR = os.path.expanduser( + "~/Library/Containers/com.tencent.xinWeChat/Data/Documents/xwechat_files/your_wxid/db_storage" + ) _DEFAULT_PROCESS = "WeChat" else: _DEFAULT_TEMPLATE_DIR = r"D:\xwechat_files\your_wxid\db_storage"