diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 4eacf85..373151b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,11 +4,12 @@ - @@ -673,7 +673,8 @@ - diff --git a/app/DataBase/hard_link.py b/app/DataBase/hard_link.py index 0a922d0..f93fc50 100644 --- a/app/DataBase/hard_link.py +++ b/app/DataBase/hard_link.py @@ -4,6 +4,8 @@ import sqlite3 import threading import xml.etree.ElementTree as ET +from app.log import log + lock = threading.Lock() DB = None cursor = None @@ -56,10 +58,9 @@ def get_md5_from_xml(content): return md5_value +@log def get_image(content, thumb=False): md5 = get_md5_from_xml(content) - # md5 = 'bc37a58c32cb203ee9ac587b068e5853' - # md5 = '41895664fc5a77878e2155fc96209a19' result = get_image_by_md5(binascii.unhexlify(md5)) if result: # print(result) diff --git a/app/DataBase/output_pc.py b/app/DataBase/output_pc.py index 65ca029..8dead80 100644 --- a/app/DataBase/output_pc.py +++ b/app/DataBase/output_pc.py @@ -5,10 +5,10 @@ import os from PyQt5.QtCore import pyqtSignal, QThread from . import msg -from ..person_pc import MePC - from ..DataBase import hard_link +from ..person_pc import MePC from ..util import get_abs_path + if not os.path.exists('./data/聊天记录'): os.mkdir('./data/聊天记录') @@ -718,13 +718,8 @@ const chatMessages = [ avatar = 'myhead.png' if is_send else 'tahead.png' timestamp = message[5] self.progressSignal.emit(index) - - if type_ == 1: - str_content = str_content.replace('"', '\\"').replace('{', '\\{').replace('}', '\\}').replace('\n', - '\\n').replace( - "'", "\\'") - str_content = escape_js_and_html(str_content) if type_ == 1: + str_content = escape_js_and_html(str_content) if self.is_5_min(timestamp): f.write( f'''{{ type:0, text: '{str_time}',is_send:0,avatar_path:''}},''' diff --git a/app/util/dat2pic.py b/app/util/dat2pic.py index 53e4ea0..4710e7d 100644 --- a/app/util/dat2pic.py +++ b/app/util/dat2pic.py @@ -44,6 +44,8 @@ def decode_dat(file_path, out_path): :param file_path: dat文件路径 :return: 无 """ + if not os.path.exists(file_path): + return None file_type, decode_code = get_code(file_path) if decode_code == -1: diff --git a/app/util/path.py b/app/util/path.py index 3112ba8..a9819f0 100644 --- a/app/util/path.py +++ b/app/util/path.py @@ -12,12 +12,8 @@ if not os.path.exists('./data/image'): def get_abs_path(path): # return os.path.join(os.getcwd(), 'app/data/icons/404.png') if path: - # if os.path.exists(os.path.join()) - # print(path, os.path.join(MePC().wx_dir, path), MePC().wx_dir) - output_path = dat2pic.decode_dat(os.path.join(MePC().wx_dir, path), './data/image') - base_path = os.getcwd() + "/data/image" - output_path = dat2pic.decode_dat(os.path.join(MePC().wx_dir, path), base_path) #'./data/image') - return output_path + output_path = dat2pic.decode_dat(os.path.join(MePC().wx_dir, path), base_path) # './data/image') + return output_path if output_path else ':/icons/icons/404.png' else: return ':/icons/icons/404.png'