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

Get plugin name for development ZIP during installation #578

Merged
merged 4 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions backend/src/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from io import BytesIO
from logging import getLogger
from os import R_OK, W_OK, path, listdir, access, mkdir
from re import sub
from shutil import rmtree
from time import time
from zipfile import ZipFile
Expand Down Expand Up @@ -162,12 +163,6 @@ async def _install(self, artifact: str, name: str, version: str, hash: str):
current_plugin_order = self.settings.getSetting("pluginOrder")[:]
if self.loader.watcher:
self.loader.watcher.disabled = True
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 if the file is a local file or a URL
if artifact.startswith("file://"):
Expand Down Expand Up @@ -198,6 +193,28 @@ async def _install(self, artifact: str, name: str, version: str, hash: str):
if res.status != 200:
logger.error(f"Server did not accept install count increment request. code: {res.status}")

if res_zip and version == "dev":
with ZipFile(res_zip) as plugin_zip:
plugin_json_list = [file for file in plugin_zip.namelist() if file.endswith("/plugin.json") and file.count("/") == 1]

if len(plugin_json_list) == 0:
logger.fatal("No plugin.json found in plugin ZIP")
return

elif len(plugin_json_list) > 1:
logger.fatal("Multiple plugin.json found in plugin ZIP")
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.")

# Check to make sure we got the file
if res_zip is None:
logger.fatal(f"Could not fetch {artifact}")
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/toaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class Toaster extends Logger {
if (
currentNode?.memoizedProps?.className?.startsWith?.('gamepadtoasts_GamepadToastPlaceholder') ||
currentNode?.memoizedProps?.className?.startsWith?.('toastmanager_ToastPlaceholder') ||
currentNode?.memoizedProps?.className?.startsWith?.('toastmanager_ToastPopup')
currentNode?.memoizedProps?.className?.startsWith?.('toastmanager_ToastPopup') ||
currentNode?.memoizedProps?.className?.startsWith?.('gamepadtoasts_GamepadToastPopup')
) {
this.log(`Toaster root was found in ${iters} recursion cycles`);
return currentNode;
Expand Down
Loading