fix: find_image_key 三个 fallback 入口路径展开 + 方案2 hint (#71)
* fix: find_image_key 三个 fallback CLI 入口对齐 config.load_config 路径展开 PR #63 给 config.load_config() 加了 expanduser + expandvars, 但 find_image_key.py / find_image_key_macos.py / find_image_key_monitor.py 三个 CLI 入口的 main() 为了让单测注入隔离 config (find_image_key_macos.py docstring 明文写着), 走 raw json.load(config_path), 绕开了 load_config 那层路径展开. 用户 config.json 里写 "db_dir": "~/Documents/..." 或 "$HOME/Documents/..." 时, 下游拼出的 attach_dir 仍带 ~ / $HOME 字面字符, glob *_t.dat 扫不到 → find_image_key.py / monitor.py 报 "No V2 .dat files found", macOS 文件 dispatcher 还会误报"请先在微信中查看 1-2 张图片让微信生成 V2 .dat 文件", 但磁盘上 attach 已经塞满了 .dat. 三个文件各加 1 行 expanduser(expandvars(...)), 与 PR #63 / config.py:213 对齐, 不动 main() 既有的 raw json.load(为保留单测注入口子). * fix(find_image_key_macos): 方案2 V2 _t.dat 样本不足时补一行下一步指引 dispatcher 层 (找不到 V2 模板分支) 已有"请先在微信中查看 1-2 张图片让微信 生成 V2 .dat 文件"指引, 但 _find_via_bruteforce 子路径在 V2 _t.dat 样本 < 3 时只 print "样本不足 (需 >= 3 个), 无法投票反推 xor_key", 用户不知该做什么. 加一行等价 hint, 与 dispatcher 层 UX 风格保持一致.
This commit is contained in:
@@ -337,7 +337,7 @@ def main():
|
|||||||
with open(config_path, encoding="utf-8") as f:
|
with open(config_path, encoding="utf-8") as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
|
||||||
db_dir = config['db_dir']
|
db_dir = os.path.expanduser(os.path.expandvars(config['db_dir']))
|
||||||
base_dir = os.path.dirname(db_dir)
|
base_dir = os.path.dirname(db_dir)
|
||||||
attach_dir = os.path.join(base_dir, 'msg', 'attach')
|
attach_dir = os.path.join(base_dir, 'msg', 'attach')
|
||||||
|
|
||||||
|
|||||||
@@ -494,6 +494,8 @@ def _find_via_bruteforce(db_dir, attach_dir, templates):
|
|||||||
if not xres:
|
if not xres:
|
||||||
print("[!] 方案2: V2 .dat 样本不足 (需 >= 3 个), 无法投票反推 xor_key",
|
print("[!] 方案2: V2 .dat 样本不足 (需 >= 3 个), 无法投票反推 xor_key",
|
||||||
flush=True)
|
flush=True)
|
||||||
|
print(" 请先在微信中再看 1-2 张图片,让微信生成更多 V2 .dat 文件",
|
||||||
|
flush=True)
|
||||||
return None
|
return None
|
||||||
xor_key, votes, total = xres
|
xor_key, votes, total = xres
|
||||||
if votes == total:
|
if votes == total:
|
||||||
@@ -607,6 +609,7 @@ def main(config_path=None):
|
|||||||
if not db_dir:
|
if not db_dir:
|
||||||
print("[!] config.json 中未配置 db_dir", file=sys.stderr, flush=True)
|
print("[!] config.json 中未配置 db_dir", file=sys.stderr, flush=True)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
db_dir = os.path.expanduser(os.path.expandvars(db_dir))
|
||||||
print(f"[*] db_dir = {db_dir}", flush=True)
|
print(f"[*] db_dir = {db_dir}", flush=True)
|
||||||
|
|
||||||
# 短路:如果已有 image_aes_key 且仍能在所有模板上验证通过,直接退出
|
# 短路:如果已有 image_aes_key 且仍能在所有模板上验证通过,直接退出
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ def main():
|
|||||||
with open(config_path, encoding="utf-8") as f:
|
with open(config_path, encoding="utf-8") as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
|
||||||
db_dir = config['db_dir']
|
db_dir = os.path.expanduser(os.path.expandvars(config['db_dir']))
|
||||||
base_dir = os.path.dirname(db_dir)
|
base_dir = os.path.dirname(db_dir)
|
||||||
attach_dir = os.path.join(base_dir, 'msg', 'attach')
|
attach_dir = os.path.join(base_dir, 'msg', 'attach')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user