From 13dd68797cdc1f9a433240080defc444ac182f92 Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Tue, 12 Aug 2025 16:58:31 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8Dwebui=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=8F=92=E4=BB=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin_store/data_source.py | 26 +++++++++++++++---- zhenxun/utils/repo_utils/file_manager.py | 8 ++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/zhenxun/builtin_plugins/plugin_store/data_source.py b/zhenxun/builtin_plugins/plugin_store/data_source.py index 2614ea3e..668e125d 100644 --- a/zhenxun/builtin_plugins/plugin_store/data_source.py +++ b/zhenxun/builtin_plugins/plugin_store/data_source.py @@ -163,13 +163,17 @@ class StoreManager: @classmethod async def get_plugin_by_value( - cls, index_or_module: str, is_update: bool = False + cls, + index_or_module: str, + is_update: bool = False, + is_remove: bool = False, ) -> tuple[StorePluginInfo, bool]: """获取插件信息 参数: index_or_module: 插件索引或模块名 is_update: 是否是更新插件 + is_remove: 是否是移除插件 异常: PluginStoreException: 插件不存在 @@ -196,10 +200,22 @@ class StoreManager: break if not plugin_info: raise PluginStoreException(f"插件不存在: {plugin_key}") - if not is_update and plugin_info.module in [p[0] for p in db_plugin_list]: + + modules = [p[0] for p in db_plugin_list] + + if is_remove: + if plugin_info.module not in modules: + raise PluginStoreException(f"插件 {plugin_info.name} 未安装,无法移除") + return plugin_info, is_external + + if is_update: + if plugin_info.module not in modules: + raise PluginStoreException(f"插件 {plugin_info.name} 未安装,无法更新") + return plugin_info, is_external + + if plugin_info.module in modules: raise PluginStoreException(f"插件 {plugin_info.name} 已安装,无需重复安装") - if plugin_info.module not in [p[0] for p in db_plugin_list] and is_update: - raise PluginStoreException(f"插件 {plugin_info.name} 未安装,无法更新") + return plugin_info, is_external @classmethod @@ -310,7 +326,7 @@ class StoreManager: 返回: str: 返回消息 """ - plugin_info, _ = await cls.get_plugin_by_value(index_or_module) + plugin_info, _ = await cls.get_plugin_by_value(index_or_module, is_remove=True) path = BASE_PATH if plugin_info.github_url: path = BASE_PATH / "plugins" diff --git a/zhenxun/utils/repo_utils/file_manager.py b/zhenxun/utils/repo_utils/file_manager.py index 43a87a7b..1e9226c7 100644 --- a/zhenxun/utils/repo_utils/file_manager.py +++ b/zhenxun/utils/repo_utils/file_manager.py @@ -154,7 +154,10 @@ class RepoFileManager: ) results.append((f, content)) except Exception as e: - logger.warning(f"获取阿里云文件内容失败: {file_path}", LOG_COMMAND, e=e) + if "code: 404" not in str(e): + logger.warning( + f"获取阿里云文件内容失败: {file_path}", LOG_COMMAND, e=e + ) if not ignore_error: raise logger.debug(f"获取阿里云文件内容: {[r[0] for r in results]}", LOG_COMMAND) @@ -526,7 +529,7 @@ class RepoFileManager: content_bytes = content.encode("utf-8") else: content_bytes = content - logger.warning(f"写入文件: {local_path}") + logger.debug(f"写入文件: {local_path}") async with aiofiles.open(local_path, "wb") as f: await f.write(content_bytes) result.success = True @@ -535,6 +538,7 @@ class RepoFileManager: len(content.encode("utf-8") if isinstance(content, str) else content) for _, content in file_contents ) + logger.info(f"下载文件成功: {[f[0] for f in file_contents]}") return result except Exception as e: logger.error(f"下载文件失败: {e}")