尝试优化更新内容
This commit is contained in:
@@ -181,17 +181,18 @@ class MessageStorage:
|
||||
file_path = os.path.join(group_dir, file_name)
|
||||
|
||||
skipped = False
|
||||
|
||||
web_path = None
|
||||
# ===== 5. 写文件 =====
|
||||
if not os.path.isfile(file_path):
|
||||
with open(file_path, "wb") as f:
|
||||
f.write(data)
|
||||
else:
|
||||
skipped = True
|
||||
|
||||
# ===== 6. 更新数据库 =====
|
||||
web_path = f"/static/images/{room_id}/{file_name}"
|
||||
self.message_db.update_message_image_file_path(msg.msg_id, web_path)
|
||||
if not skipped:
|
||||
logger.warning(f"跳过图片保存{room_id}-{file_name}")
|
||||
# ===== 6. 更新数据库 =====
|
||||
web_path = f"/static/images/{room_id}/{file_name}"
|
||||
self.message_db.update_message_image_file_path(msg.msg_id, web_path)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
|
||||
Reference in New Issue
Block a user