Skip to content

Commit

Permalink
Merge branch 'main' of github.com:SteamDeckHomebrew/decky-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
AAGaming00 committed Dec 14, 2024
2 parents 4b47a8a + 43f2232 commit 6bf21bf
Show file tree
Hide file tree
Showing 4 changed files with 450 additions and 294 deletions.
31 changes: 22 additions & 9 deletions backend/decky_loader/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,16 @@ async def _install(self, artifact: str, name: str, version: str, hash: str):
# 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:
Expand Down Expand Up @@ -213,14 +221,19 @@ async def _install(self, artifact: str, name: str, version: str, hash: str):
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:
Expand Down
Loading

0 comments on commit 6bf21bf

Please sign in to comment.