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: