From c800be65a3ff4fba30320f1723415d638f8531b2 Mon Sep 17 00:00:00 2001 From: tcmofashi Date: Sat, 22 Mar 2025 20:14:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E4=BA=8660=E5=88=86?= =?UTF-8?q?=E8=A7=A3=E6=B3=95=E4=BC=9A=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E7=8E=B0=E5=9C=A8=E6=94=B9=E7=94=A85?= =?UTF-8?q?=E5=88=86=E8=A7=A3=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/chat/emoji_manager.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/plugins/chat/emoji_manager.py b/src/plugins/chat/emoji_manager.py index 57c2b0b85..b0366ec07 100644 --- a/src/plugins/chat/emoji_manager.py +++ b/src/plugins/chat/emoji_manager.py @@ -248,20 +248,14 @@ class EmojiManager: if existing_emoji_by_path["_id"] != existing_emoji_by_hash["_id"]: logger.error(f"[错误] 表情包已存在但记录不一致: {filename}") db.emoji.delete_one({"_id": existing_emoji_by_path["_id"]}) - db.emoji.update_one( - {"_id": existing_emoji_by_hash["_id"]}, {"$set": {"path": image_path, "filename": filename}} - ) - existing_emoji_by_hash["path"] = image_path - existing_emoji_by_hash["filename"] = filename - existing_emoji = existing_emoji_by_hash + db.emoji.delete_one({"_id": existing_emoji_by_hash["_id"]}) + existing_emoji = None + else: + existing_emoji = existing_emoji_by_hash elif existing_emoji_by_hash: logger.error(f"[错误] 表情包hash已存在但path不存在: {filename}") - db.emoji.update_one( - {"_id": existing_emoji_by_hash["_id"]}, {"$set": {"path": image_path, "filename": filename}} - ) - existing_emoji_by_hash["path"] = image_path - existing_emoji_by_hash["filename"] = filename - existing_emoji = existing_emoji_by_hash + db.emoji.delete_one({"_id": existing_emoji_by_hash["_id"]}) + existing_emoji = None elif existing_emoji_by_path: logger.error(f"[错误] 表情包path已存在但hash不存在: {filename}") db.emoji.delete_one({"_id": existing_emoji_by_path["_id"]})