Compare commits

..

2 Commits

Author SHA1 Message Date
AAGaming f015e00561 more updater fixes 2022-07-15 12:57:51 -04:00
AAGaming e07827cdb5 catch rm errors 2022-07-15 12:36:16 -04:00
3 changed files with 11 additions and 12 deletions
+2 -2
View File
@@ -33,7 +33,7 @@ class Tab:
return (await self.websocket.receive_json()) if receive else None
raise RuntimeError("Websocket not opened")
async def evaluate_js(self, js, run_async=False, manage_socket=True):
async def evaluate_js(self, js, run_async=False, manage_socket=True, get_result=True):
if manage_socket:
await self.open_websocket()
@@ -45,7 +45,7 @@ class Tab:
"userGesture": True,
"awaitPromise": run_async
}
})
}, get_result)
if manage_socket:
await self.client.close()
+6 -6
View File
@@ -59,7 +59,7 @@ class Updater:
return {
"current": self.localVer,
"remote": self.remoteVer,
"updatable": self.remoteVer != None
"updatable": self.localVer != None
}
else:
return {"current": "unknown", "updatable": False}
@@ -91,8 +91,10 @@ class Updater:
async with ClientSession() as web:
async with web.request("GET", download_url, ssl=helpers.get_ssl_context(), allow_redirects=True) as res:
total = int(res.headers.get('content-length', 0))
remove(path.join(getcwd(), "PluginLoader"))
try:
remove(path.join(getcwd(), "PluginLoader"))
except:
pass
with open(path.join(getcwd(), "PluginLoader"), "wb") as out:
progress = 0
raw = 0
@@ -101,8 +103,7 @@ class Updater:
raw += len(c)
new_progress = round((raw / total) * 100)
if progress != new_progress:
if new_progress - progress>= 2:
self.context.loop.create_task(tab.evaluate_js(f"window.DeckyUpdater.updateProgress({progress})", False, False))
self.context.loop.create_task(tab.evaluate_js(f"window.DeckyUpdater.updateProgress({new_progress})", False, False, False))
progress = new_progress
with open(path.join(getcwd(), ".loader.version"), "w") as out:
@@ -117,4 +118,3 @@ class Updater:
async def do_restart(self):
call(["systemctl", "daemon-reload"])
call(["systemctl", "restart", "plugin_loader"])
exit(0)
@@ -52,9 +52,9 @@ export default function UpdaterSettings() {
>
{updateProgress == -1 ? (
<DialogButton
disabled={!versionInfo?.updatable || !versionInfo?.remote || checkingForUpdates}
disabled={!versionInfo?.updatable || checkingForUpdates}
onClick={
versionInfo?.remote?.tag_name == versionInfo?.current
!versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current
? async () => {
setCheckingForUpdates(true);
const res = (await callUpdaterMethod('check_for_updates')) as { result: VerInfo };
@@ -79,7 +79,7 @@ export default function UpdaterSettings() {
>
{checkingForUpdates
? 'Checking'
: versionInfo?.remote?.tag_name == versionInfo?.current
: !versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current
? 'Check For Updates'
: 'Install Update'}
</DialogButton>
@@ -88,7 +88,6 @@ export default function UpdaterSettings() {
layout="inline"
bottomSeparator={false}
nProgress={updateProgress}
nTransitionSec={0.01}
indeterminate={reloading}
sOperationText={reloading ? 'Reloading' : 'Updating'}
/>