Merge pull request #624 from MuWinds/refactor

Fix:配置文件不存在的时候先创建目录,否则复制文件的时候报:FileNotFoundError
This commit is contained in:
SengokuCola
2025-04-01 11:35:08 +08:00
committed by GitHub

View File

@@ -43,6 +43,8 @@ def update_config():
# 检查配置文件是否存在 # 检查配置文件是否存在
if not old_config_path.exists(): if not old_config_path.exists():
logger.info("配置文件不存在,从模板创建新配置") logger.info("配置文件不存在,从模板创建新配置")
#创建文件夹
old_config_dir.mkdir(parents=True, exist_ok=True)
shutil.copy2(template_path, old_config_path) shutil.copy2(template_path, old_config_path)
logger.info(f"已创建新配置文件,请填写后重新运行: {old_config_path}") logger.info(f"已创建新配置文件,请填写后重新运行: {old_config_path}")
# 如果是新创建的配置文件,直接返回 # 如果是新创建的配置文件,直接返回