From 76a6218be64cb3300dcb6ec1920b5959590b0a57 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sat, 1 Feb 2025 19:31:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dwebui=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BB=8E=E6=9C=AC=E5=9C=B0=E4=B8=8A=E4=BC=A0=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/star/star_manager.py | 9 ++++----- astrbot/dashboard/routes/plugin.py | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/astrbot/core/star/star_manager.py b/astrbot/core/star/star_manager.py index 4f6bbb398..1854c5490 100644 --- a/astrbot/core/star/star_manager.py +++ b/astrbot/core/star/star_manager.py @@ -359,8 +359,9 @@ class PluginManager: plugin.activated = True - def install_plugin_from_file(self, zip_file_path: str): - desti_dir = os.path.join(self.plugin_store_path, os.path.basename(zip_file_path)) + async def install_plugin_from_file(self, zip_file_path: str): + dir_name = os.path.basename(zip_file_path).replace(".zip", "") + desti_dir = os.path.join(self.plugin_store_path, dir_name) self.updator.unzip_file(zip_file_path, desti_dir) # remove the zip @@ -368,6 +369,4 @@ class PluginManager: os.remove(zip_file_path) except BaseException as e: logger.warning(f"删除插件压缩包失败: {str(e)}") - - self._check_plugin_dept_update() - + await self.reload() diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index b2bdd8d67..5f774322d 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -67,9 +67,9 @@ class PluginRoute(Route): file = await request.files file = file['file'] logger.info(f"正在安装用户上传的插件 {file.filename}") - file_path = f"data/temp/{uuid.uuid4()}.zip" + file_path = f"data/temp/{file.filename}" await file.save(file_path) - self.plugin_manager.install_plugin_from_file(file_path) + await self.plugin_manager.install_plugin_from_file(file_path) logger.info(f"安装插件 {file.filename} 成功") return Response().ok(None, "安装成功。").__dict__ except Exception as e: