diff options
| author | AAGaming <aagaming@riseup.net> | 2024-12-13 22:31:09 -0500 |
|---|---|---|
| committer | AAGaming <aagaming@riseup.net> | 2024-12-13 22:31:09 -0500 |
| commit | 6bf21bf2ad1ab160aeb904f8cfb1dd60941a2885 (patch) | |
| tree | a50660c7500462a65bf1e97d607241f59ea04aa2 /backend/decky_loader/browser.py | |
| parent | 4b47a8abeb7a827b98b7bc37ee81f07935020837 (diff) | |
| parent | 43f22329e1b2ca4f707e6c748ea9c013337de8b2 (diff) | |
| download | decky-loader-6bf21bf2ad1ab160aeb904f8cfb1dd60941a2885.tar.gz decky-loader-6bf21bf2ad1ab160aeb904f8cfb1dd60941a2885.zip | |
Merge branch 'main' of github.com:SteamDeckHomebrew/decky-loader
Diffstat (limited to 'backend/decky_loader/browser.py')
| -rw-r--r-- | backend/decky_loader/browser.py | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/backend/decky_loader/browser.py b/backend/decky_loader/browser.py index af23ed0c..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: @@ -213,14 +221,19 @@ class PluginBrowser: return else: - name = sub(r"/.+$", "", plugin_json_list[0]) - - 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.") + 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.") # Check to make sure we got the file if res_zip is None: |
