fix 更换选项,无法自动启用新的数据库

This commit is contained in:
xaoyaoo 2024-08-06 22:40:19 +08:00
parent fbfa78788f
commit c8ee2ea8d1
2 changed files with 14 additions and 3 deletions

View File

@ -19,7 +19,7 @@ from flask import Flask, request, render_template, g, Blueprint, send_file, make
from pywxdump import get_core_db, all_merge_real_time_db, get_wx_db from pywxdump import get_core_db, all_merge_real_time_db, get_wx_db
from pywxdump.api.rjson import ReJson, RqJson from pywxdump.api.rjson import ReJson, RqJson
from pywxdump.api.utils import get_conf, get_conf_wxids, set_conf, error9999, gen_base64, validate_title, \ from pywxdump.api.utils import get_conf, get_conf_wxids, set_conf, error9999, gen_base64, validate_title, \
get_conf_local_wxid, ls_loger get_conf_local_wxid, ls_loger, random_str
from pywxdump import get_wx_info, WX_OFFS, batch_decrypt, BiasAddr, merge_db, decrypt_merge, merge_real_time_db from pywxdump import get_wx_info, WX_OFFS, batch_decrypt, BiasAddr, merge_db, decrypt_merge, merge_real_time_db
from pywxdump.db import DBHandler, download_file, export_csv, export_json from pywxdump.db import DBHandler, download_file, export_csv, export_json
@ -123,7 +123,7 @@ def init_key():
# 显示堆栈信息 # 显示堆栈信息
ls_loger.error(f"{e}", exc_info=True) ls_loger.error(f"{e}", exc_info=True)
db_config = { db_config = {
"key": "merge_all", "key": random_str(16),
"type": "sqlite", "type": "sqlite",
"path": merge_save_path_new "path": merge_save_path_new
} }
@ -166,7 +166,12 @@ def init_nokey():
return ReJson(1002, body=f"my_wxid is required: {my_wxid}") return ReJson(1002, body=f"my_wxid is required: {my_wxid}")
key = get_conf(g.caf, my_wxid, "key") key = get_conf(g.caf, my_wxid, "key")
db_config = {
"key": random_str(16),
"type": "sqlite",
"path": merge_path
}
set_conf(g.caf, my_wxid, "db_config", db_config)
set_conf(g.caf, my_wxid, "merge_path", merge_path) set_conf(g.caf, my_wxid, "merge_path", merge_path)
set_conf(g.caf, my_wxid, "wx_path", wx_path) set_conf(g.caf, my_wxid, "wx_path", wx_path)
set_conf(g.caf, my_wxid, "key", key) set_conf(g.caf, my_wxid, "key", key)

View File

@ -8,7 +8,9 @@
import base64 import base64
import json import json
import os import os
import random
import re import re
import string
import traceback import traceback
from .rjson import ReJson from .rjson import ReJson
from functools import wraps from functools import wraps
@ -123,3 +125,7 @@ def gen_base64(path):
base64_encoded_js = base64.b64encode(js_code).decode('utf-8') base64_encoded_js = base64.b64encode(js_code).decode('utf-8')
return start_str + base64_encoded_js return start_str + base64_encoded_js
def random_str(num=16):
return ''.join(random.sample(string.ascii_letters + string.digits, num))