修复无法自动解密(解密报错的问题)
This commit is contained in:
1 parent
d2f37eba5b
commit
b9abf401f9
4 files changed
+83
-52
No files matched your search
+22
-1
@@ -75,18 +75,39 @@ def init_key():
|
||||
if not my_wxid:
|
||||
return ReJson(1002, body=f"my_wxid is required: {my_wxid}")
|
||||
|
||||
old_merge_save_path = read_session(g.sf, my_wxid, "merge_path")
|
||||
if os.path.exists(old_merge_save_path):
|
||||
pmsg = ParsingMSG(old_merge_save_path)
|
||||
pmsg.close_all_connection()
|
||||
|
||||
out_path = os.path.join(g.tmp_path, "decrypted", my_wxid) if my_wxid else os.path.join(g.tmp_path, "decrypted")
|
||||
# 检查文件夹中文件是否被占用
|
||||
if os.path.exists(out_path):
|
||||
try:
|
||||
shutil.rmtree(out_path)
|
||||
except PermissionError as e:
|
||||
# 显示堆栈信息
|
||||
logging.error(f"{e}", exc_info=True)
|
||||
return ReJson(2001, body=str(e))
|
||||
|
||||
code, merge_save_path = decrypt_merge(wx_path=wx_path, key=key, outpath=out_path)
|
||||
time.sleep(1)
|
||||
if code:
|
||||
save_session(g.sf, my_wxid, "merge_path", merge_save_path)
|
||||
# 移动merge_save_path到g.tmp_path/my_wxid
|
||||
if not os.path.exists(os.path.join(g.tmp_path, my_wxid)):
|
||||
os.makedirs(os.path.join(g.tmp_path, my_wxid))
|
||||
merge_save_path_new = os.path.join(g.tmp_path, my_wxid, "merge_all.db")
|
||||
shutil.move(merge_save_path, str(merge_save_path_new))
|
||||
|
||||
# 删除out_path
|
||||
if os.path.exists(out_path):
|
||||
try:
|
||||
shutil.rmtree(out_path)
|
||||
except PermissionError as e:
|
||||
# 显示堆栈信息
|
||||
logging.error(f"{e}", exc_info=True)
|
||||
|
||||
save_session(g.sf, my_wxid, "merge_path", merge_save_path_new)
|
||||
save_session(g.sf, my_wxid, "wx_path", wx_path)
|
||||
save_session(g.sf, my_wxid, "key", key)
|
||||
save_session(g.sf, my_wxid, "my_wxid", my_wxid)
|
||||
|
||||
Reference in new issue
Block a user