From 3c4d57bb9d64eb481dc93c927ef7568951699a29 Mon Sep 17 00:00:00 2001 From: Garden12138 <847686279@qq.com> Date: Thu, 10 Jul 2025 17:17:46 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9AFixed=20the=20problem=20of=20plugin?= =?UTF-8?q?=20installation=20failure=20caused=20by=20inconsistent=20plugin?= =?UTF-8?q?=20IDs,=20such=20as=20LM=20Studio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/services/plugin/plugin_service.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/api/services/plugin/plugin_service.py b/api/services/plugin/plugin_service.py index a8b64f27db..9be455b670 100644 --- a/api/services/plugin/plugin_service.py +++ b/api/services/plugin/plugin_service.py @@ -353,26 +353,30 @@ class PluginService: manager = PluginInstaller() + # collect actual plugin_unique_identifiers + actual_plugin_unique_identifiers = [] + metas = [] + # check if already downloaded for plugin_unique_identifier in plugin_unique_identifiers: try: manager.fetch_plugin_manifest(tenant_id, plugin_unique_identifier) # already downloaded, skip + actual_plugin_unique_identifiers.append(plugin_unique_identifier) + metas.append({"plugin_unique_identifier": plugin_unique_identifier}) except Exception: # plugin not installed, download and upload pkg pkg = download_plugin_pkg(plugin_unique_identifier) - manager.upload_pkg(tenant_id, pkg, verify_signature) + upload_result = manager.upload_pkg(tenant_id, pkg, verify_signature) + # use upload_result plugin_unique_identifier + actual_plugin_unique_identifiers.append(upload_result.unique_identifier) + metas.append({"plugin_unique_identifier": upload_result.unique_identifier}) return manager.install_from_identifiers( tenant_id, - plugin_unique_identifiers, + actual_plugin_unique_identifiers, PluginInstallationSource.Marketplace, - [ - { - "plugin_unique_identifier": plugin_unique_identifier, - } - for plugin_unique_identifier in plugin_unique_identifiers - ], + metas, ) @staticmethod