mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
fix(plugins_initializer): 优化插件恢复的容错处理
- 添加单个插件恢复失败的异常处理,使用 continue 跳过 - 确保单个插件恢复失败不影响其他插件继续恢复
This commit is contained in:
@@ -138,7 +138,6 @@ def restore_plugins():
|
|||||||
if not SystemUtils.is_docker():
|
if not SystemUtils.is_docker():
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
|
||||||
# 使用绝对路径确保准确性
|
# 使用绝对路径确保准确性
|
||||||
plugins_dir = settings.ROOT_PATH / "app" / "plugins"
|
plugins_dir = settings.ROOT_PATH / "app" / "plugins"
|
||||||
backup_dir = settings.CONFIG_PATH / "plugins_backup"
|
backup_dir = settings.CONFIG_PATH / "plugins_backup"
|
||||||
@@ -157,7 +156,7 @@ def restore_plugins():
|
|||||||
restored_count = 0
|
restored_count = 0
|
||||||
for item in backup_dir.iterdir():
|
for item in backup_dir.iterdir():
|
||||||
target_path = plugins_dir / item.name
|
target_path = plugins_dir / item.name
|
||||||
|
try:
|
||||||
# 如果是目录,且目录内有内容
|
# 如果是目录,且目录内有内容
|
||||||
if item.is_dir() and any(item.iterdir()):
|
if item.is_dir() and any(item.iterdir()):
|
||||||
if target_path.exists():
|
if target_path.exists():
|
||||||
@@ -170,6 +169,9 @@ def restore_plugins():
|
|||||||
shutil.copy2(item, target_path)
|
shutil.copy2(item, target_path)
|
||||||
logger.info(f"已恢复插件文件: {item.name}")
|
logger.info(f"已恢复插件文件: {item.name}")
|
||||||
restored_count += 1
|
restored_count += 1
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"恢复插件 {item.name} 时发生错误: {str(e)}")
|
||||||
|
continue
|
||||||
|
|
||||||
logger.info(f"插件恢复完成,共恢复 {restored_count} 个项目")
|
logger.info(f"插件恢复完成,共恢复 {restored_count} 个项目")
|
||||||
|
|
||||||
@@ -179,6 +181,3 @@ def restore_plugins():
|
|||||||
logger.info(f"已删除插件备份目录: {backup_dir}")
|
logger.info(f"已删除插件备份目录: {backup_dir}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"删除备份目录失败: {str(e)}")
|
logger.warning(f"删除备份目录失败: {str(e)}")
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"插件恢复失败: {str(e)}")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user