diff options
| author | Party Wumpus <48649272+PartyWumpus@users.noreply.github.com> | 2024-05-13 14:42:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-13 14:42:55 +0100 |
| commit | 372771a228c9fbb31ec4a943dd6cfa9915741c6c (patch) | |
| tree | 5cd9cc5bd5cd2814e5d588232342b754324747e3 /backend | |
| parent | 675b6d5ef8c3f84e5758d675ae0ff94ebb601de4 (diff) | |
| download | decky-loader-372771a228c9fbb31ec4a943dd6cfa9915741c6c.tar.gz decky-loader-372771a228c9fbb31ec4a943dd6cfa9915741c6c.zip | |
plugin install progress (#614)
* Frontend progress bars
* Backend bit
* closure is stale i think so no closure for you
* Fix formatting of the progress svgs
* Reset progress bar when new plugin starts downloading
Diffstat (limited to 'backend')
| -rw-r--r-- | backend/decky_loader/browser.py | 14 | ||||
| -rw-r--r-- | backend/locales/en-US.json | 9 |
2 files changed, 23 insertions, 0 deletions
diff --git a/backend/decky_loader/browser.py b/backend/decky_loader/browser.py index 6fa71bb2..ea036ba8 100644 --- a/backend/decky_loader/browser.py +++ b/backend/decky_loader/browser.py @@ -151,6 +151,8 @@ class PluginBrowser: self.loader.watcher.disabled = False async def _install(self, artifact: str, name: str, version: str, hash: str): + await self.loader.ws.emit("loader/plugin_download_start", name) + await self.loader.ws.emit("loader/plugin_download_info", 5, "Store.download_progress_info.start") # Will be set later in code res_zip = None @@ -164,12 +166,17 @@ class PluginBrowser: # Check if the file is a local file or a URL if artifact.startswith("file://"): logger.info(f"Installing {name} from local ZIP file (Version: {version})") + await self.loader.ws.emit("loader/plugin_download_info", 10, "Store.download_progress_info.open_zip") res_zip = BytesIO(open(artifact[7:], "rb").read()) else: logger.info(f"Installing {name} from URL (Version: {version})") + await self.loader.ws.emit("loader/plugin_download_info", 10, "Store.download_progress_info.download_zip") + async with ClientSession() as client: logger.debug(f"Fetching {artifact}") res = await client.get(artifact, ssl=get_ssl_context()) + #TODO track progress of this download in chunks like with decky updates + #TODO but squish with min 15 and max 75 if res.status == 200: logger.debug("Got 200. Reading...") data = await res.read() @@ -178,6 +185,7 @@ class PluginBrowser: else: logger.fatal(f"Could not fetch from URL. {await res.text()}") + await self.loader.ws.emit("loader/plugin_download_info", 80, "Store.download_progress_info.increment_count") storeUrl = "" match self.settings.getSetting("store", 0): case 0: storeUrl = "https://plugins.deckbrew.xyz/plugins" # default @@ -190,6 +198,7 @@ class PluginBrowser: if res.status != 200: logger.error(f"Server did not accept install count increment request. code: {res.status}") + await self.loader.ws.emit("loader/plugin_download_info", 85, "Store.download_progress_info.parse_zip") if res_zip and version == "dev": with ZipFile(res_zip) as plugin_zip: plugin_json_list = [file for file in plugin_zip.namelist() if file.endswith("/plugin.json") and file.count("/") == 1] @@ -219,12 +228,15 @@ class PluginBrowser: # If plugin is installed, uninstall it if isInstalled: + await self.loader.ws.emit("loader/plugin_download_info", 90, "Store.download_progress_info.uninstalling_previous") try: logger.debug("Uninstalling existing plugin...") await self.uninstall_plugin(name) except: logger.error(f"Plugin {name} could not be uninstalled.") + + await self.loader.ws.emit("loader/plugin_download_info", 95, "Store.download_progress_info.installing_plugin") # Install the plugin logger.debug("Unzipping...") ret = self._unzip_to_plugin_dir(res_zip, name, hash) @@ -232,6 +244,7 @@ class PluginBrowser: plugin_folder = self.find_plugin_folder(name) assert plugin_folder is not None plugin_dir = path.join(self.plugin_path, plugin_folder) + #TODO count again from 0% to 100% quickly for this one if it does anything ret = await self._download_remote_binaries_for_plugin_with_name(plugin_dir) if ret: logger.info(f"Installed {name} (Version: {version})") @@ -251,6 +264,7 @@ class PluginBrowser: logger.fatal(f"SHA-256 Mismatch!!!! {name} (Version: {version})") if self.loader.watcher: self.loader.watcher.disabled = False + await self.loader.ws.emit("loader/plugin_download_finish", name) async def request_plugin_install(self, artifact: str, name: str, version: str, hash: str, install_type: PluginInstallType): request_id = str(time()) diff --git a/backend/locales/en-US.json b/backend/locales/en-US.json index 1898b29b..94e1ed3d 100644 --- a/backend/locales/en-US.json +++ b/backend/locales/en-US.json @@ -231,6 +231,15 @@ "store_testing_warning": { "desc": "You can use this store channel to test bleeding-edge plugin versions. Be sure to leave feedback on GitHub so the plugin can be updated for all users.", "label": "Welcome to the Testing Store Channel" + }, + "download_progress_info": { + "start": "Initializing", + "open_zip": "Opening zip file", + "download_zip": "Downloading plugin", + "increment_count": "Incrementing download count", + "parse_zip": "Parsing zip file", + "uninstalling_previous": "Uninstalling previous copy", + "installing_plugin": "Installing plugin" } }, "StoreSelect": { |
