summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrainDoctor <traindoctor@protonmail.com>2022-10-23 13:41:12 -0700
committerGitHub <noreply@github.com>2022-10-23 13:41:12 -0700
commit6749c78ed71764fd26a15d00bf5be1b74133b6e8 (patch)
tree8e6a71809ac81375cc25ddc5e865b8fec5dd96e0
parent4ad15568cd2802f9499bd3961c5fe24391745502 (diff)
downloaddecky-loader-6749c78ed71764fd26a15d00bf5be1b74133b6e8.tar.gz
decky-loader-6749c78ed71764fd26a15d00bf5be1b74133b6e8.zip
During update, download updates first before removing old plugin files (#223)v2.3.0-pre3
* Remove old nightly support and unused logging * Removed legacy code + added logic to account for offline update attempts * Update backend/browser.py Co-authored-by: AAGaming <aa@mail.catvibers.me> * Update backend/browser.py Co-authored-by: AAGaming <aa@mail.catvibers.me> * Update frontend/src/toaster.tsx Co-authored-by: AAGaming <aa@mail.catvibers.me> * Use str instead of String (I was tired okay...) * Remove false logic * look for plugins not having remote_binary in pkg Co-authored-by: AAGaming <aa@mail.catvibers.me>
-rw-r--r--backend/browser.py18
-rw-r--r--backend/updater.py5
-rw-r--r--frontend/src/components/settings/pages/general/index.tsx10
3 files changed, 13 insertions, 20 deletions
diff --git a/backend/browser.py b/backend/browser.py
index 8e2209f1..3007ae18 100644
--- a/backend/browser.py
+++ b/backend/browser.py
@@ -57,7 +57,7 @@ class PluginBrowser:
if access(packageJsonPath, R_OK):
with open(packageJsonPath, 'r') as f:
packageJson = json.load(f)
- if len(packageJson["remote_binary"]) > 0:
+ if "remote_binary" in packageJson and len(packageJson["remote_binary"]) > 0:
# create bin directory if needed.
rc=call(["chmod", "-R", "777", pluginBasePath])
if access(pluginBasePath, W_OK):
@@ -97,7 +97,7 @@ class PluginBrowser:
plugin = json.load(f)
if plugin['name'] == name:
- return path.join(self.plugin_path, folder)
+ return str(path.join(self.plugin_path, folder))
except:
logger.debug(f"skipping {folder}")
@@ -124,12 +124,15 @@ class PluginBrowser:
self.loader.watcher.disabled = False
async def _install(self, artifact, name, version, hash):
+ isInstalled = False
if self.loader.watcher:
self.loader.watcher.disabled = True
try:
- await self.uninstall_plugin(name)
+ pluginFolderPath = self.find_plugin_folder(name)
+ if pluginFolderPath:
+ isInstalled = True
except:
- logger.error(f"Plugin {name} not installed, skipping uninstallation")
+ logger.error(f"Failed to determine if {name} is already installed, continuing anyway.")
logger.info(f"Installing {name} (Version: {version})")
async with ClientSession() as client:
logger.debug(f"Fetching {artifact}")
@@ -139,6 +142,12 @@ class PluginBrowser:
data = await res.read()
logger.debug(f"Read {len(data)} bytes")
res_zip = BytesIO(data)
+ if isInstalled:
+ try:
+ logger.debug("Uninstalling existing plugin...")
+ await self.uninstall_plugin(name)
+ except:
+ logger.error(f"Plugin {name} could not be uninstalled.")
logger.debug("Unzipping...")
ret = self._unzip_to_plugin_dir(res_zip, name, hash)
if ret:
@@ -151,7 +160,6 @@ class PluginBrowser:
self.loader.plugins.pop(name, None)
await sleep(1)
self.loader.import_plugin(path.join(plugin_dir, "main.py"), plugin_dir)
- # await inject_to_tab("SP", "window.syncDeckyPlugins()")
else:
logger.fatal(f"Failed Downloading Remote Binaries")
else:
diff --git a/backend/updater.py b/backend/updater.py
index 402c152b..ed1520ab 100644
--- a/backend/updater.py
+++ b/backend/updater.py
@@ -104,14 +104,9 @@ class Updater:
elif selectedBranch == 1:
logger.debug("release type: pre-release")
self.remoteVer = next(filter(lambda ver: ver["prerelease"] and ver["tag_name"].startswith("v") and ver["tag_name"].find("-pre"), remoteVersions), None)
- # elif selectedBranch == 2:
- # logger.debug("release type: nightly")
- # self.remoteVer = next(filter(lambda ver: ver["prerelease"] and ver["tag_name"].startswith("v") and ver["tag_name"].find("nightly"), remoteVersions), None)
else:
logger.error("release type: NOT FOUND")
raise ValueError("no valid branch found")
- # doesn't make it to this line below or farther
- # logger.debug("Remote Version: %s" % self.remoteVer.find("name"))
logger.info("Updated remote version information")
tab = await get_tab("SP")
await tab.evaluate_js(f"window.DeckyPluginLoader.notifyUpdates()", False, True, False)
diff --git a/frontend/src/components/settings/pages/general/index.tsx b/frontend/src/components/settings/pages/general/index.tsx
index 768cfafb..6ce9f682 100644
--- a/frontend/src/components/settings/pages/general/index.tsx
+++ b/frontend/src/components/settings/pages/general/index.tsx
@@ -15,18 +15,8 @@ export default function GeneralSettings({
setIsDeveloper: (val: boolean) => void;
}) {
const [pluginURL, setPluginURL] = useState('');
- // const [checked, setChecked] = useState(false); // store these in some kind of State instead
return (
<div>
- {/* <Field
- label="A Toggle with an icon"
- icon={<FaShapes style={{ display: 'block' }} />}
- >
- <Toggle
- value={checked}
- onChange={(e) => setChecked(e)}
- />
- </Field> */}
<UpdaterSettings />
<BranchSelect />
<RemoteDebuggingSettings />