fix: decrypt_db SKIP 与失败分开计数, 不把无密钥误报为失败 (#72)
decrypt_db 在遍历 .db 时, 遇到没匹配 key 的 db (e.g. migrate/ unspportmsg.db 这种迁移残留 / 微信内部不加密的库) print "SKIP: xxx (无密钥)" 后会 failed += 1, summary 里就把这类合理跳过的 db 报成 "失败"。用户每次跑完都得 grep 一下确认那 N 个失败到底是真问题还是 SKIP 噪音。 参照 pytest (passed/failed/skipped) / rsync 的标准做法, SKIP 单独 计数, 不进 failed: - 加 skipped 计数器 - SKIP 分支走 skipped += 1 (其余 HMAC / SQLite 校验失败仍记 failed) - summary 多显示一栏 "K 跳过(无密钥)" 只动这 3 处; main() 末尾本来就没基于 failed 设 exit code, 不影响 退出码语义。 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -140,13 +140,14 @@ def main():
|
||||
|
||||
success = 0
|
||||
failed = 0
|
||||
skipped = 0
|
||||
total_bytes = 0
|
||||
|
||||
for rel, path, sz in db_files:
|
||||
key_info = get_key_info(keys, rel)
|
||||
if not key_info:
|
||||
print(f"SKIP: {rel} (无密钥)")
|
||||
failed += 1
|
||||
skipped += 1
|
||||
continue
|
||||
|
||||
enc_key = bytes.fromhex(key_info["enc_key"])
|
||||
@@ -176,7 +177,7 @@ def main():
|
||||
failed += 1
|
||||
|
||||
print(f"\n{'='*60}")
|
||||
print(f"结果: {success} 成功, {failed} 失败, 共 {len(db_files)} 个")
|
||||
print(f"结果: {success} 成功, {failed} 失败, {skipped} 跳过(无密钥), 共 {len(db_files)} 个")
|
||||
print(f"解密数据量: {total_bytes/1024/1024/1024:.1f}GB")
|
||||
print(f"解密文件在: {OUT_DIR}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user