Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Plugins installed with zip or link do not show up until decky restarts #527

Closed
4 tasks done
PartyWumpus opened this issue Aug 18, 2023 · 4 comments
Closed
4 tasks done
Labels
bug Something isn't working

Comments

@PartyWumpus
Copy link
Member

Please confirm

  • I have searched existing issues
  • This issue is not a duplicate of an existing one
  • I have checked the common issues section in the readme file
  • I have attached logs to this bug report (failure to include logs will mean your issue may not be responded to).

Bug Report Description

Install a plugin with zip or with link in the developer settings, it will not show up in the plugins list until decky restarts (restarting the frontend alone does not fix it, so it's a problem in the backend). Looking through the code, I can't really tell why this happens, as the function calls look the same. (maybe the InstallType is wrong?)

Expected Behaviour

The plugin should appear right away.

SteamOS version

SteamOS 3.5 Main, and my EndevourOS desktop

Selected Update Channel

Prerelease

Have you modified the read-only filesystem at any point?

No response

Logs

deckylog.txt

@PartyWumpus PartyWumpus added the bug Something isn't working label Aug 18, 2023
@eXhumer
Copy link
Contributor

eXhumer commented Jan 24, 2024

Hello. I came across this as well when I had to install TabMaster's new update and did a bit more digging through the code to figure out the problem, it seems to be due to the code in src/backend/browser.py backend code, more specifically the _install method inside it.

First issue is when the function tries to determine if the plugin is already installed, it fails this check until the ZIP file is named exactly the same as the plugin name

pluginFolderPath = self.find_plugin_folder(name)

Any ZIP which is not named exactly as the plugin name will fail this check always and will assume the plugin is not installed already.

def find_plugin_folder(self, name: str) -> str | None:
for folder in listdir(self.plugin_path):
try:
with open(path.join(self.plugin_path, folder, 'plugin.json'), "r", encoding="utf-8") as f:
plugin = json.load(f)
if plugin['name'] == name:
return folder
except:
logger.debug(f"skipping {folder}")

This piece of code is never executed as a result of the failed check

# If plugin is installed, uninstall it
if isInstalled:
try:
logger.debug("Uninstalling existing plugin...")
await self.uninstall_plugin(name)
except:
logger.error(f"Plugin {name} could not be uninstalled.")

And this is the final bit of mistake. ZIP is extracted, but since the find_plugin_folder fails, it raises AssertionError because of an empty plugin_folder and halts the rest of the code execution.

# Install the plugin
logger.debug("Unzipping...")
ret = self._unzip_to_plugin_dir(res_zip, name, hash)
if ret:
plugin_folder = self.find_plugin_folder(name)
assert plugin_folder is not None

Install from ZIP/URL will correctly work only if the ZIP file is named the same as the plugin name.

@eXhumer
Copy link
Contributor

eXhumer commented Jan 24, 2024

This ultimately boils down to what "name" is assigned when requesting to install the plugin.

When using the plugin storefront or reinstalling it, the plugin name is provided directly from the frontend. While install from URL, it instead strips out the .zip extension from the filename and uses it as the name.

export async function installFromURL(url: string) {
const splitURL = url.split('/');
await window.DeckyPluginLoader.callServerMethod('install_plugin', {
name: splitURL[splitURL.length - 1].replace('.zip', ''),
artifact: url,
});
}
export async function requestPluginInstall(plugin: string, selectedVer: StorePluginVersion, installType: InstallType) {
const artifactUrl = selectedVer.artifact ?? pluginUrl(selectedVer.hash);
await window.DeckyPluginLoader.callServerMethod('install_plugin', {
name: plugin,
artifact: artifactUrl,
version: selectedVer.name,
hash: selectedVer.hash,
install_type: installType,
});
}

The best suggestion I have is to fetch the ZIP and read the plugin.json directly from the ZIP to get the plugin name correctly while installing from developer mode.

@PartyWumpus
Copy link
Member Author

Good job figuring that one out, thank you.
Will be good to get this fixed.

TrainDoctor pushed a commit that referenced this issue Feb 15, 2024
* fix: get plugin name for dev builds from ZIP (#527)

Signed-off-by: eXhumer <exhumer1@protonmail.com>
PartyWumpus pushed a commit that referenced this issue Feb 20, 2024
* fix: get plugin name for dev builds from ZIP (#527)

Signed-off-by: eXhumer <exhumer1@protonmail.com>
@PartyWumpus
Copy link
Member Author

This was fixed a while ago, forgot to close the issue. Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants