mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-09 09:31:18 +08:00
修复自定义词文件写入问题
This commit is contained in:
parent
a04a8e68e6
commit
1b901535ab
@ -350,18 +350,7 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow, QCursorGif):
|
||||
|
||||
def set_my_info(self, wxid):
|
||||
self.avatar = QPixmap()
|
||||
try:
|
||||
img_bytes = misc_db.get_avatar_buffer(wxid)
|
||||
except:
|
||||
logger.error(f'数据库错误:\n{traceback.format_exc()}')
|
||||
QMessageBox.critical(self, "数据库错误", "请重启电脑后重试")
|
||||
close_db()
|
||||
import shutil
|
||||
try:
|
||||
shutil.rmtree(DB_DIR)
|
||||
except:
|
||||
pass
|
||||
return
|
||||
img_bytes = misc_db.get_avatar_buffer(wxid)
|
||||
if not img_bytes:
|
||||
return
|
||||
if img_bytes[:4] == b'\x89PNG':
|
||||
@ -377,7 +366,7 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow, QCursorGif):
|
||||
shutil.rmtree(DB_DIR)
|
||||
except:
|
||||
pass
|
||||
QMessageBox.critical(self, "数据库错误", "请重启电脑后重试")
|
||||
QMessageBox.critical(self, "数据库错误", "数据库错误,请删除app文件夹后重启电脑再运行软件")
|
||||
return
|
||||
me = Me()
|
||||
me.set_avatar(img_bytes)
|
||||
|
@ -229,11 +229,11 @@ class DecryptThread(QThread):
|
||||
tasks.append([self.key, inpath, output_path])
|
||||
else:
|
||||
try:
|
||||
name,suffix = file.split('.')
|
||||
name, suffix = file.split('.')
|
||||
if suffix.startswith('db_SQLITE'):
|
||||
inpath = os.path.join(root, file)
|
||||
# print(inpath)
|
||||
output_path = os.path.join(output_dir, name+'.db')
|
||||
output_path = os.path.join(output_dir, name + '.db')
|
||||
tasks.append([self.key, inpath, output_path])
|
||||
except:
|
||||
continue
|
||||
@ -250,17 +250,9 @@ class DecryptThread(QThread):
|
||||
import shutil
|
||||
if os.path.exists(target_database):
|
||||
os.remove(target_database)
|
||||
try:
|
||||
shutil.copy2(os.path.join(DB_DIR, 'MSG0.db'), target_database) # 使用一个数据库文件作为模板
|
||||
except FileNotFoundError:
|
||||
logger.error(traceback.format_exc())
|
||||
self.errorSignal.emit(True)
|
||||
shutil.copy2(os.path.join(DB_DIR, 'MSG0.db'), target_database) # 使用一个数据库文件作为模板
|
||||
# 合并数据库
|
||||
try:
|
||||
merge_databases(source_databases, target_database)
|
||||
except FileNotFoundError:
|
||||
logger.error(traceback.format_exc())
|
||||
QMessageBox.critical("错误", "数据库不存在\n请检查微信版本是否为最新")
|
||||
merge_databases(source_databases, target_database)
|
||||
|
||||
# 音频数据库文件
|
||||
target_database = os.path.join(DB_DIR, 'MediaMSG.db')
|
||||
@ -268,17 +260,10 @@ class DecryptThread(QThread):
|
||||
if os.path.exists(target_database):
|
||||
os.remove(target_database)
|
||||
source_databases = [os.path.join(DB_DIR, f"MediaMSG{i}.db") for i in range(1, 50)]
|
||||
try:
|
||||
shutil.copy2(os.path.join(DB_DIR, 'MediaMSG0.db'), target_database) # 使用一个数据库文件作为模板
|
||||
except FileNotFoundError:
|
||||
logger.error(traceback.format_exc())
|
||||
self.errorSignal.emit(True)
|
||||
shutil.copy2(os.path.join(DB_DIR, 'MediaMSG0.db'), target_database) # 使用一个数据库文件作为模板
|
||||
|
||||
# 合并数据库
|
||||
try:
|
||||
merge_MediaMSG_databases(source_databases, target_database)
|
||||
except FileNotFoundError:
|
||||
logger.error(traceback.format_exc())
|
||||
QMessageBox.critical("错误", "数据库不存在\n请检查微信版本是否为最新")
|
||||
merge_MediaMSG_databases(source_databases, target_database)
|
||||
self.okSignal.emit('ok')
|
||||
# self.signal.emit('100')
|
||||
|
||||
@ -294,7 +279,7 @@ class MyThread(QThread):
|
||||
pass
|
||||
|
||||
def get_bias_add(self, version):
|
||||
url = urljoin(SERVER_API_URL,'wxBiasAddr')
|
||||
url = urljoin(SERVER_API_URL, 'wxBiasAddr')
|
||||
data = {
|
||||
'version': version
|
||||
}
|
||||
|
@ -122,11 +122,11 @@ class SettingControl(QWidget, Ui_Form):
|
||||
f.write(stopwords)
|
||||
if os.path.exists('./app/data/new_words.txt'):
|
||||
with open('./app/data/new_words.txt', 'r', encoding='utf-8') as f:
|
||||
stopwords = set(f.read().splitlines())
|
||||
new_words = set(f.read().splitlines())
|
||||
self.plainTextEdit_newword.setPlainText(' '.join(new_words))
|
||||
else:
|
||||
self.plainTextEdit_newword.setPlainText(' '.join(new_words))
|
||||
stopwords = '\n'.join(stopwords)
|
||||
stopwords = '\n'.join(new_words)
|
||||
with open('./app/data/new_words.txt', 'w', encoding='utf-8') as f:
|
||||
f.write(stopwords)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user