修复无法自动解密(解密报错的问题)
This commit is contained in:
parent
d2f37eba5b
commit
b9abf401f9
@ -28,4 +28,4 @@ except:
|
||||
# PYWXDUMP_ROOT_PATH = os.path.dirname(__file__)
|
||||
# db_init = DBPool("DBPOOL_INIT")
|
||||
|
||||
__version__ = "3.0.16"
|
||||
__version__ = "3.0.17"
|
||||
|
@ -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)
|
||||
|
@ -69,6 +69,13 @@ class DatabaseBase:
|
||||
logging.info(f"关闭数据库 - {self._db_path}")
|
||||
self._db_connection = None
|
||||
|
||||
def close_all_connection(self):
|
||||
for db_path in self._connection_pool:
|
||||
if self._connection_pool[db_path]:
|
||||
self._connection_pool[db_path].close()
|
||||
logging.info(f"关闭数据库 - {db_path}")
|
||||
self._connection_pool[db_path] = None
|
||||
|
||||
def show__singleton_instances(self):
|
||||
print(self._singleton_instances)
|
||||
|
||||
|
@ -236,6 +236,7 @@ def merge_db(db_paths, save_path="merge.db", CreateTime: int = 0, endCreateTime:
|
||||
# 获取表名
|
||||
sql = f"SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"
|
||||
tables = execute_sql(db, sql)
|
||||
try:
|
||||
for table in tables:
|
||||
table = table[0]
|
||||
if table == "sqlite_sequence":
|
||||
@ -290,6 +291,8 @@ def merge_db(db_paths, save_path="merge.db", CreateTime: int = 0, endCreateTime:
|
||||
except Exception as e:
|
||||
logging.error(f"error: {alias}\n{table}\n{sql}\n{src_data}\n{len(src_data)}\n{e}\n**********")
|
||||
outdb.commit()
|
||||
except Exception as e:
|
||||
logging.error(f"fun(merge_db) error: {alias}\n{e}\n**********")
|
||||
db.close()
|
||||
outdb.close()
|
||||
return save_path
|
||||
|
Loading…
Reference in New Issue
Block a user