diff options
| author | AAGaming <aa@mail.catvibers.me> | 2022-06-22 23:22:27 -0400 |
|---|---|---|
| committer | AAGaming <aa@mail.catvibers.me> | 2022-06-22 23:22:27 -0400 |
| commit | 9619c52720c97ef74842b15aa732dd0a8d6fb26a (patch) | |
| tree | ceb46763b919ef8b5f7ac2c0cc0522ad9b6c95b9 /backend | |
| parent | 80b223180e9a5f86bb6f6a42fb4660862872f7ab (diff) | |
| download | decky-loader-9619c52720c97ef74842b15aa732dd0a8d6fb26a.tar.gz decky-loader-9619c52720c97ef74842b15aa732dd0a8d6fb26a.zip | |
add settings page with install from URL option
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/browser.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/backend/browser.py b/backend/browser.py index a62e282a..1b802291 100644 --- a/backend/browser.py +++ b/backend/browser.py @@ -31,7 +31,7 @@ class PluginBrowser: def _unzip_to_plugin_dir(self, zip, name, hash): zip_hash = sha256(zip.getbuffer()).hexdigest() - if zip_hash != hash: + if hash and (zip_hash != hash): return False zip_file = ZipFile(zip) zip_file.extractall(self.plugin_path) @@ -45,9 +45,8 @@ class PluginBrowser: rmtree(path.join(self.plugin_path, name), ignore_errors=True) self.log.info(f"Installing {artifact} (Version: {version})") async with ClientSession() as client: - url = f"https://github.com/{artifact}/archive/refs/tags/{version}.zip" - self.log.debug(f"Fetching {url}") - res = await client.get(url) + self.log.debug(f"Fetching {artifact}") + res = await client.get(artifact) if res.status == 200: self.log.debug("Got 200. Reading...") data = await res.read() @@ -67,14 +66,14 @@ class PluginBrowser: else: self.log.fatal(f"SHA-256 Mismatch!!!! {artifact} (Version: {version})") else: - self.log.fatal(f"Could not fetch from github. {await res.text()}") + self.log.fatal(f"Could not fetch from URL. {await res.text()}") async def redirect_to_store(self, request): return web.Response(status=302, headers={"Location": self.store_url}) async def install_plugin(self, request): data = await request.post() - get_event_loop().create_task(self.request_plugin_install(data["artifact"], data["version"], data["hash"])) + get_event_loop().create_task(self.request_plugin_install(data["artifact"], data.get("version", "dev"), data.get("hash", False))) return web.Response(text="Requested plugin install") async def request_plugin_install(self, artifact, version, hash): @@ -82,7 +81,7 @@ class PluginBrowser: self.install_requests[request_id] = PluginInstallContext(artifact, version, hash) tab = await get_tab("SP") await tab.open_websocket() - await tab.evaluate_js(f"DeckyPluginLoader.addPluginInstallPrompt('{artifact}', '{version}', '{request_id}')") + await tab.evaluate_js(f"DeckyPluginLoader.addPluginInstallPrompt('{artifact}', '{version}', '{request_id}', '{hash}')") async def confirm_plugin_install(self, request_id): request = self.install_requests.pop(request_id) |
