From 9e07f85451e08e20318251a8b6303b85767d5773 Mon Sep 17 00:00:00 2001 From: yibo Date: Sat, 25 Jul 2026 13:06:39 +0800 Subject: [PATCH] fix(wechat-viewer): 账号自动发现跳过非账号目录,少发 38 次多余 su 探测 --- wechat-viewer/config.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wechat-viewer/config.py b/wechat-viewer/config.py index 9f45f45..8756275 100644 --- a/wechat-viewer/config.py +++ b/wechat-viewer/config.py @@ -3,6 +3,7 @@ import subprocess import json import os +import re from pathlib import Path BASE_DIR = Path(__file__).parent @@ -68,6 +69,8 @@ def _get_custom_name(account_id): pass return None +_ACCOUNT_DIR_RE = re.compile(r"^[0-9a-f]{32}$") + def discover_accounts(): accounts = [] base = "/data/data/com.tencent.mm/MicroMsg" @@ -80,9 +83,11 @@ def discover_accounts(): line = line.strip() if not line: continue + folder = os.path.basename(line.rstrip("/")) + if not _ACCOUNT_DIR_RE.match(folder): + continue # 跳过微信自己的缓存/功能目录(CronetCache/emoji/jscache/...),不是账号 db_path = os.path.join(line, "EnMicroMsg.db") if _su_exists(db_path): - folder = os.path.basename(line.rstrip("/")) key = _get_key_for_account(folder) # 名字优先级:自定义名 > 从DB读 > hash前缀 name = _get_custom_name(folder) or _get_nickname(db_path, key) or folder[:8] -- libgit2 0.21.4