mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 06:32:04 +00:00
add settings page with install from URL option
This commit is contained in:
+6
-7
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user