Compare commits

..

6 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
AAGaming 103d43e7c9 fix updater 2022-07-15 12:31:30 -04:00
AAGaming 23b7df0ce2 wait 30s before first update check 2022-07-15 12:25:27 -04:00
AAGaming a5671e19ce fix ci AGAIN 2022-07-15 12:20:05 -04:00
AAGaming f2fbd399fe allow users to manually check for updates 2022-07-15 12:16:57 -04:00
4 changed files with 51 additions and 33 deletions
+1 -1
View File
@@ -118,7 +118,7 @@ jobs:
run: |
export VERSION=${{ steps.old_tag.outputs.tag }}
export COMMIT=$(git log -1 --pretty=format:%h)
echo ::set-output name=tag_name::$(sed -r 's/-pre(.*)?$//' <<< $VERSION)-$COMMIT-pre
echo ::set-output name=tag_name::$(sed -r 's/(-.*)?-pre$//' <<< $VERSION)-$COMMIT-pre
- name: Push tag 📤
uses: rickstaa/action-create-tag@v1.3.2
+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()
+19 -12
View File
@@ -8,7 +8,7 @@ from aiohttp import ClientSession, web
from injector import inject_to_tab, get_tab
from os import getcwd, path
from os import getcwd, path, remove
from subprocess import call
@@ -22,7 +22,8 @@ class Updater:
self.updater_methods = {
"get_version": self.get_version,
"do_update": self.do_update,
"do_restart": self.do_restart
"do_restart": self.do_restart,
"check_for_updates": self.check_for_updates
}
self.remoteVer = None
try:
@@ -58,19 +59,24 @@ class Updater:
return {
"current": self.localVer,
"remote": self.remoteVer,
"updatable": self.remoteVer != None
"updatable": self.localVer != None
}
else:
return {"current": "unknown", "updatable": False}
async def check_for_updates(self):
async with ClientSession() as web:
async with web.request("GET", "https://api.github.com/repos/SteamDeckHomebrew/decky-loader/releases", ssl=helpers.get_ssl_context()) as res:
remoteVersions = await res.json()
self.remoteVer = next(filter(lambda ver: ver["prerelease"] and ver["tag_name"].startswith("v") and ver["tag_name"].endswith("-pre"), remoteVersions), None)
logger.info("Updated remote version information")
return await self.get_version()
async def version_reloader(self):
await sleep(30)
while True:
try:
async with ClientSession() as web:
async with web.request("GET", "https://api.github.com/repos/SteamDeckHomebrew/decky-loader/releases", ssl=helpers.get_ssl_context()) as res:
remoteVersions = await res.json()
self.remoteVer = next(filter(lambda ver: ver["prerelease"] and ver["tag_name"].startswith("v") and ver["tag_name"].endswith("-pre"), remoteVersions), None)
logger.info("Updated remote version information")
await self.check_for_updates()
except:
pass
await sleep(60 * 60) # 1 hour
@@ -85,7 +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))
try:
remove(path.join(getcwd(), "PluginLoader"))
except:
pass
with open(path.join(getcwd(), "PluginLoader"), "wb") as out:
progress = 0
raw = 0
@@ -94,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:
@@ -110,4 +118,3 @@ class Updater:
async def do_restart(self):
call(["systemctl", "daemon-reload"])
call(["systemctl", "restart", "plugin_loader"])
exit(0)
@@ -24,6 +24,7 @@ export default function UpdaterSettings() {
const [versionInfo, setVersionInfo] = useState<VerInfo | null>(null);
const [updateProgress, setUpdateProgress] = useState<number>(-1);
const [reloading, setReloading] = useState<boolean>(false);
const [checkingForUpdates, setCheckingForUpdates] = useState<boolean>(false);
useEffect(() => {
(async () => {
const res = (await callUpdaterMethod('get_version')) as { result: VerInfo };
@@ -51,32 +52,42 @@ export default function UpdaterSettings() {
>
{updateProgress == -1 ? (
<DialogButton
disabled={
!versionInfo?.updatable || !versionInfo?.remote || versionInfo.remote.tag_name == versionInfo.current
disabled={!versionInfo?.updatable || checkingForUpdates}
onClick={
!versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current
? async () => {
setCheckingForUpdates(true);
const res = (await callUpdaterMethod('check_for_updates')) as { result: VerInfo };
setVersionInfo(res.result);
setCheckingForUpdates(false);
}
: async () => {
window.DeckyUpdater = {
updateProgress: (i) => {
setUpdateProgress(i);
},
finish: async () => {
setUpdateProgress(0);
setReloading(true);
await finishUpdate();
},
};
setUpdateProgress(0);
callUpdaterMethod('do_update');
}
}
onClick={async () => {
window.DeckyUpdater = {
updateProgress: (i) => {
setUpdateProgress(i);
},
finish: async () => {
setUpdateProgress(0);
setReloading(true);
await finishUpdate();
},
};
setUpdateProgress(0);
callUpdaterMethod('do_update');
}}
>
Update
{checkingForUpdates
? 'Checking'
: !versionInfo?.remote || versionInfo?.remote?.tag_name == versionInfo?.current
? 'Check For Updates'
: 'Install Update'}
</DialogButton>
) : (
<ProgressBarWithInfo
layout="inline"
bottomSeparator={false}
nProgress={updateProgress}
nTransitionSec={0.01}
indeterminate={reloading}
sOperationText={reloading ? 'Reloading' : 'Updating'}
/>