From 07f6ce631792eaaeca51ff4e66e8e37a4e18a567 Mon Sep 17 00:00:00 2001 From: tretrauit Date: Thu, 25 Apr 2024 21:46:03 +0700 Subject: [PATCH] fix: hdiffpatch download --- worthless/__init__.py | 2 +- worthless/cli.py | 0 worthless/installer.py | 32 ++++++++++++++++++++++---------- 3 files changed, 23 insertions(+), 11 deletions(-) mode change 100644 => 100755 worthless/cli.py diff --git a/worthless/__init__.py b/worthless/__init__.py index 0043fae..f61be5c 100644 --- a/worthless/__init__.py +++ b/worthless/__init__.py @@ -4,4 +4,4 @@ Launcher = launcher.Launcher Installer = installer.Installer -__version__ = "2.2.20" +__version__ = "2.2.22" diff --git a/worthless/cli.py b/worthless/cli.py old mode 100644 new mode 100755 diff --git a/worthless/installer.py b/worthless/installer.py index 05ab256..bc69027 100644 --- a/worthless/installer.py +++ b/worthless/installer.py @@ -26,7 +26,7 @@ async def _download_file(file_url: str, file_name: str, file_path: Path | str, f headers = {} file_path = Path(file_path).joinpath(file_name) if overwrite: - await file_path.unlink(missing_ok=True) + file_path.unlink(missing_ok=True) if file_path.exists(): cur_len = (file_path.stat()).st_size headers |= { @@ -78,19 +78,28 @@ class HDiffPatch: @staticmethod def _get_platform_arch(): + processor = platform.machine() match platform.system(): case "Windows": - match platform.architecture()[0]: - case "32bit": + match processor: + case "i386": return "windows32" - case "64bit": + case "x86_64": return "windows64" + case "arm": + return "windows_arm32" + case "arm64": + return "windows_arm64" case "Linux": - match platform.architecture()[0]: - case "32bit": + match processor: + case "i386": return "linux32" - case "64bit": + case "x86_64": return "linux64" + case "arm": + return "linux_arm32" + case "arm64": + return "linux_arm64" case "Darwin": return "macos" @@ -140,10 +149,13 @@ class HDiffPatch: rsp = await session.get("https://api.github.com/repos/{}/{}/releases/latest".format(owner, repo), params={"Headers": "Accept: application/vnd.github.v3+json"}) rsp.raise_for_status() + archive_processor = self._get_platform_arch() for asset in (await rsp.json())["assets"]: - if asset["name"].endswith(".zip") and "linux" not in asset["name"] and "windows" not in asset["name"] \ - and "macos" not in asset["name"] and "android" not in asset["name"]: - return asset + if not asset["name"].endswith(".zip"): + continue + if archive_processor not in asset["name"]: + continue + return asset async def get_latest_release_url(self): asset = await self._get_latest_release_info()