From 6d59e97130eb5001b24abb3e5d6ddb23163ded77 Mon Sep 17 00:00:00 2001 From: zhiyucn Date: Sun, 1 Jun 2025 19:04:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(heartFC=5FCycleinfo):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E5=88=9B=E5=BB=BA=E5=A4=B1=E8=B4=A5=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=E5=92=8C=E5=A4=87?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当目录创建失败时,捕获异常并打印错误信息,同时将日志文件写入到temp目录下作为备用方案 --- src/chat/focus_chat/heartFC_Cycleinfo.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/chat/focus_chat/heartFC_Cycleinfo.py b/src/chat/focus_chat/heartFC_Cycleinfo.py index 129a58af8..989461089 100644 --- a/src/chat/focus_chat/heartFC_Cycleinfo.py +++ b/src/chat/focus_chat/heartFC_Cycleinfo.py @@ -98,7 +98,12 @@ class CycleDetail: # 如果目录不存在,则创建目录 dir_name = os.path.dirname(file_path) if dir_name and not os.path.exists(dir_name): - os.makedirs(dir_name, exist_ok=True) + try: + os.makedirs(dir_name, exist_ok=True) + except Exception as e: + print(f"创建目录 {dir_name} 失败: {e}") + print(f"日志将会写入到temp目录下") + file_path = os.path.join("temp", os.path.basename(file_path)) # 写入文件 import json