fix: 修复webui无法从本地上传插件的问题

This commit is contained in:
Soulter
2025-02-01 19:31:29 +08:00
parent 6c1de1bbd6
commit 76a6218be6
2 changed files with 6 additions and 7 deletions
+4 -5
View File
@@ -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()
+2 -2
View File
@@ -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: