mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-21 01:52:35 +08:00
修复再次解密数据库时显示msg.db占用问题
This commit is contained in:
parent
a4987a0af1
commit
6c518d3eb8
@ -72,6 +72,11 @@ def get_image(content, thumb=False):
|
||||
return dat_image
|
||||
|
||||
|
||||
def close():
|
||||
if DB:
|
||||
DB.close()
|
||||
|
||||
|
||||
# 6b02292eecea118f06be3a5b20075afc_t
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,6 +1,7 @@
|
||||
import os.path
|
||||
import sqlite3
|
||||
import threading
|
||||
import time
|
||||
|
||||
lock = threading.Lock()
|
||||
DB = None
|
||||
@ -33,7 +34,8 @@ def get_avatar_buffer(userName):
|
||||
lock.acquire(True)
|
||||
try:
|
||||
cursor.execute(sql, [userName])
|
||||
except AttributeError:
|
||||
except:
|
||||
time.sleep(0.5)
|
||||
init_database()
|
||||
finally:
|
||||
cursor.execute(sql, [userName])
|
||||
@ -46,5 +48,11 @@ def get_avatar_buffer(userName):
|
||||
return None
|
||||
|
||||
|
||||
def close():
|
||||
global DB
|
||||
if DB:
|
||||
DB.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
get_avatar_buffer('wxid_al2oan01b6fn11')
|
||||
|
@ -81,18 +81,14 @@ def get_message_by_num(username_, local_id):
|
||||
|
||||
|
||||
def close():
|
||||
for db in DB:
|
||||
db.close()
|
||||
global DB
|
||||
if DB:
|
||||
DB.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
msg_root_path = './Msg/'
|
||||
init_database()
|
||||
|
||||
# username = 'wxid_0o18ef858vnu22'
|
||||
# result = get_messages(username)
|
||||
# pprint(result)
|
||||
# pprint(len(result))
|
||||
result = get_message_by_num('wxid_0o18ef858vnu22', 9999999)
|
||||
print(result)
|
||||
print(result[-1][0])
|
||||
|
@ -15,7 +15,7 @@ from PyQt5.QtGui import QPixmap, QFont, QDesktopServices
|
||||
from PyQt5.QtWidgets import *
|
||||
|
||||
from app import config
|
||||
from app.DataBase import msg, misc
|
||||
from app.DataBase import msg, misc, micro_msg, hard_link
|
||||
from app.ui_pc.Icon import Icon
|
||||
from . import mainwindow
|
||||
from .chat import ChatWindow
|
||||
@ -216,7 +216,10 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow):
|
||||
def close(self) -> bool:
|
||||
del self.listWidget
|
||||
del self.stackedWidget
|
||||
misc.close()
|
||||
msg.close()
|
||||
micro_msg.close()
|
||||
hard_link.close()
|
||||
self.contact_window.close()
|
||||
|
||||
|
||||
|
@ -7,9 +7,11 @@ from PyQt5.QtCore import pyqtSignal, QThread, QUrl, QFile, QIODevice, QTextStrea
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtWidgets import QWidget, QMessageBox, QFileDialog
|
||||
|
||||
from app.DataBase import msg, micro_msg, misc, hard_link
|
||||
from app.DataBase.merge import merge_databases
|
||||
from app.decrypt import get_wx_info, decrypt
|
||||
from app.log import logger
|
||||
from app.util import path
|
||||
from . import decryptUi
|
||||
|
||||
|
||||
@ -69,6 +71,14 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
|
||||
self.lineEdit.setFocus()
|
||||
self.checkBox.setChecked(True)
|
||||
self.get_wxidSignal.emit(self.info['wxid'])
|
||||
directory = os.path.join(path.wx_path(), self.info['wxid'])
|
||||
if os.path.exists(directory):
|
||||
self.label_db_dir.setText(directory)
|
||||
self.wx_dir = directory
|
||||
self.checkBox_2.setChecked(True)
|
||||
self.ready = True
|
||||
if self.ready:
|
||||
self.label_ready.setText('已就绪')
|
||||
if self.wx_dir and os.path.exists(os.path.join(self.wx_dir)):
|
||||
self.label_ready.setText('已就绪')
|
||||
except Exception as e:
|
||||
@ -87,7 +97,7 @@ class DecryptControl(QWidget, decryptUi.Ui_Dialog):
|
||||
def select_db_dir(self):
|
||||
directory = QFileDialog.getExistingDirectory(
|
||||
self, "选取微信文件保存目录——能看到Msg文件夹",
|
||||
os.path.expanduser('~\Documents')
|
||||
path.wx_path()
|
||||
) # 起始路径
|
||||
db_dir = os.path.join(directory, 'Msg')
|
||||
if not os.path.exists(db_dir):
|
||||
@ -186,6 +196,11 @@ class DecryptThread(QThread):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
misc.close()
|
||||
msg.close()
|
||||
micro_msg.close()
|
||||
hard_link.close()
|
||||
QThread.sleep(1)
|
||||
# data.decrypt(self.db_path, self.key)
|
||||
output_dir = 'app/DataBase/Msg'
|
||||
try:
|
||||
@ -207,7 +222,7 @@ class DecryptThread(QThread):
|
||||
self.maxNumSignal.emit(len(tasks))
|
||||
for i, task in enumerate(tasks):
|
||||
decrypt.decrypt(*task)
|
||||
self.signal.emit(str(i + 1))
|
||||
self.signal.emit(str(i))
|
||||
# print(self.db_path)
|
||||
self.okSignal.emit('ok')
|
||||
# self.signal.emit('100')
|
||||
|
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import winreg
|
||||
|
||||
from app.person_pc import MePC
|
||||
from app.util import dat2pic
|
||||
@ -17,3 +18,24 @@ def get_abs_path(path):
|
||||
return output_path if output_path else ':/icons/icons/404.png'
|
||||
else:
|
||||
return ':/icons/icons/404.png'
|
||||
|
||||
|
||||
def wx_path():
|
||||
## 获取当前用户名
|
||||
users = os.path.expandvars('$HOMEPATH')
|
||||
## 找到3ebffe94.ini配置文件
|
||||
f = open(r'C:' + users + '\\AppData\\Roaming\\Tencent\\WeChat\\All Users\\config\\3ebffe94.ini')
|
||||
txt = f.read()
|
||||
f.close()
|
||||
# 打开Windows注册表
|
||||
reg_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
|
||||
"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
|
||||
# 获取“我的文档”路径的注册表键值
|
||||
documents_path_value = winreg.QueryValueEx(reg_key, "Personal")
|
||||
# 输出路径
|
||||
##读取文件将路径放到wx_location变量里
|
||||
if txt == 'MyDocument:':
|
||||
wx_location = documents_path_value[0] + '\WeChat Files'
|
||||
else:
|
||||
wx_location = txt + "\WeChat Files"
|
||||
return wx_location
|
||||
|
Loading…
Reference in New Issue
Block a user