From 8d2b252e6d5fde081255f8bdc02866cc6965b3fc Mon Sep 17 00:00:00 2001 From: Mitja Skuver Date: Sun, 13 Oct 2024 19:20:08 +0000 Subject: Fixed plugin manual zip installation getting stuck indefinitely (#706) --- backend/decky_loader/browser.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'backend/decky_loader') diff --git a/backend/decky_loader/browser.py b/backend/decky_loader/browser.py index af23ed0c..f55b269f 100644 --- a/backend/decky_loader/browser.py +++ b/backend/decky_loader/browser.py @@ -213,7 +213,19 @@ class PluginBrowser: return else: - name = sub(r"/.+$", "", plugin_json_list[0]) + plugin_json_file = plugin_json_list[0] + name = sub(r"/.+$", "", plugin_json_file) + try: + with plugin_zip.open(plugin_json_file) as f: + plugin_json_data = json.loads(f.read().decode('utf-8')) + plugin_name_from_plugin_json = plugin_json_data.get('name') + if plugin_name_from_plugin_json and plugin_name_from_plugin_json.strip(): + logger.info(f"Extracted plugin name from {plugin_json_file}: {plugin_name_from_plugin_json}") + name = plugin_name_from_plugin_json + else: + logger.warning(f"Nonexistent or invalid 'name' key value in {plugin_json_file}. Falling back to extracting from path.") + except Exception as e: + logger.error(f"Failed to read or parse {plugin_json_file}: {str(e)}. Falling back to extracting from path.") try: pluginFolderPath = self.find_plugin_folder(name) -- cgit v1.2.3 From 4c95484ccb7e7ac5f2e3d62fa8f1a8707d7f2608 Mon Sep 17 00:00:00 2001 From: Party Wumpus <48649272+PartyWumpus@users.noreply.github.com> Date: Sun, 13 Oct 2024 20:22:02 +0100 Subject: move check for if plugin was installed to the start of the function (#715) --- backend/decky_loader/browser.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'backend/decky_loader') diff --git a/backend/decky_loader/browser.py b/backend/decky_loader/browser.py index f55b269f..aa108c59 100644 --- a/backend/decky_loader/browser.py +++ b/backend/decky_loader/browser.py @@ -157,8 +157,16 @@ class PluginBrowser: # Will be set later in code res_zip = None - # Check if plugin is installed + # Check if plugin was already installed before this isInstalled = False + + try: + pluginFolderPath = self.find_plugin_folder(name) + if pluginFolderPath: + isInstalled = True + except: + logger.error(f"Failed to determine if {name} is already installed, continuing anyway.") + # Preserve plugin order before removing plugin (uninstall alters the order and removes the plugin from the list) current_plugin_order = self.settings.getSetting("pluginOrder")[:] if self.loader.watcher: @@ -227,13 +235,6 @@ class PluginBrowser: except Exception as e: logger.error(f"Failed to read or parse {plugin_json_file}: {str(e)}. Falling back to extracting from path.") - try: - pluginFolderPath = self.find_plugin_folder(name) - if pluginFolderPath: - isInstalled = True - except: - logger.error(f"Failed to determine if {name} is already installed, continuing anyway.") - # Check to make sure we got the file if res_zip is None: logger.fatal(f"Could not fetch {artifact}") -- cgit v1.2.3