## v1.5.3 (2024-03-21)
- 优化了完整流程处理逻辑: - 修改了OCR处理逻辑,当遇到已处理的图片时自动跳过并继续执行 - 改进了错误处理,避免因图片已处理而中断流程 - 优化了日志提示信息,提供更清晰的处理状态反馈 - 改进了OCRService的process_image方法: - 添加了文件存在性检查 - 添加了文件类型验证 - 添加了已处理文件检查 - 优化了错误处理和日志记录
This commit is contained in:
Binary file not shown.
+21
-8
@@ -39,14 +39,27 @@ class ConfigManager:
|
||||
"""
|
||||
if not os.path.exists(self.config_file):
|
||||
self.create_default_config()
|
||||
|
||||
try:
|
||||
self.config.read(self.config_file, encoding='utf-8')
|
||||
logger.info(f"已加载配置文件: {self.config_file}")
|
||||
except Exception as e:
|
||||
logger.error(f"加载配置文件时出错: {e}")
|
||||
logger.info("使用默认配置")
|
||||
self.create_default_config(save=False)
|
||||
else:
|
||||
try:
|
||||
# 先读取现有配置
|
||||
self.config.read(self.config_file, encoding='utf-8')
|
||||
|
||||
# 检查是否有缺失的配置项,只添加缺失的项
|
||||
for section, options in DEFAULT_CONFIG.items():
|
||||
if not self.config.has_section(section):
|
||||
self.config.add_section(section)
|
||||
|
||||
for option, value in options.items():
|
||||
if not self.config.has_option(section, option):
|
||||
self.config.set(section, option, value)
|
||||
|
||||
# 保存更新后的配置
|
||||
self.save_config()
|
||||
logger.info(f"已加载并更新配置文件: {self.config_file}")
|
||||
except Exception as e:
|
||||
logger.error(f"加载配置文件时出错: {e}")
|
||||
logger.info("使用默认配置")
|
||||
self.create_default_config(save=False)
|
||||
|
||||
def create_default_config(self, save: bool = True) -> None:
|
||||
"""创建默认配置"""
|
||||
|
||||
Reference in New Issue
Block a user