@@ -58,6 +58,7 @@ def __init__(
5858 "/plugin/update" : ("POST" , self .update_plugin ),
5959 "/plugin/update-all" : ("POST" , self .update_all_plugins ),
6060 "/plugin/uninstall" : ("POST" , self .uninstall_plugin ),
61+ "/plugin/uninstall-failed" : ("POST" , self .uninstall_failed_plugin ),
6162 "/plugin/market_list" : ("GET" , self .get_online_plugins ),
6263 "/plugin/off" : ("POST" , self .off_plugin ),
6364 "/plugin/on" : ("POST" , self .on_plugin ),
@@ -565,6 +566,34 @@ async def uninstall_plugin(self):
565566 logger .error (traceback .format_exc ())
566567 return Response ().error (str (e )).__dict__
567568
569+ async def uninstall_failed_plugin (self ):
570+ if DEMO_MODE :
571+ return (
572+ Response ()
573+ .error ("You are not permitted to do this operation in demo mode" )
574+ .__dict__
575+ )
576+
577+ post_data = await request .get_json ()
578+ dir_name = post_data .get ("dir_name" , "" )
579+ delete_config = post_data .get ("delete_config" , False )
580+ delete_data = post_data .get ("delete_data" , False )
581+ if not dir_name :
582+ return Response ().error ("缺少失败插件目录名" ).__dict__
583+
584+ try :
585+ logger .info (f"正在卸载失败插件 { dir_name } " )
586+ await self .plugin_manager .uninstall_failed_plugin (
587+ dir_name ,
588+ delete_config = delete_config ,
589+ delete_data = delete_data ,
590+ )
591+ logger .info (f"卸载失败插件 { dir_name } 成功" )
592+ return Response ().ok (None , "卸载成功" ).__dict__
593+ except Exception as e :
594+ logger .error (traceback .format_exc ())
595+ return Response ().error (str (e )).__dict__
596+
568597 async def update_plugin (self ):
569598 if DEMO_MODE :
570599 return (
0 commit comments