From 8b2d0cad8fad867369b77dc125f4bbece9d13148 Mon Sep 17 00:00:00 2001 From: tretrauit Date: Fri, 1 Apr 2022 09:43:33 +0700 Subject: [PATCH] Remove game version check in download_full_game() Fix remote archive name detection (because archive.game.latest.name doesn't contain it anymore) Signed-off-by: tretrauit --- setup.py | 2 +- worthless/installer.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index e83c1ea..061595b 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ README = (HERE / "README.md").read_text() setup( name='worthless', - version='1.3.1-1', + version='1.3.1-2', packages=['worthless', 'worthless.classes', 'worthless.classes.launcher', 'worthless.classes.installer'], url='https://git.froggi.es/tretrauit/worthless-launcher', license='MIT License', diff --git a/worthless/installer.py b/worthless/installer.py index 58b8931..e4336bc 100644 --- a/worthless/installer.py +++ b/worthless/installer.py @@ -98,11 +98,15 @@ class HDiffPatch: hpatchz_name = "hpatchz" + (".exe" if platform.system() == "Windows" else "") return self._get_hdiffpatch_exec(hpatchz_name) - async def patch_file(self, in_file, out_file, patch_file): + async def patch_file(self, in_file, out_file, patch_file, wait=False): hpatchz = self.get_hpatchz_executable() if not hpatchz: raise RuntimeError("hpatchz executable not found") - return await asyncio.create_subprocess_exec(hpatchz, "-f", in_file, patch_file, out_file) + proc = await asyncio.create_subprocess_exec(hpatchz, "-f", in_file, patch_file, out_file) + if not wait: + return proc + await proc.wait() + return proc def get_hdiffz_executable(self): hdiffz_name = "hdiffz" + (".exe" if platform.system() == "Windows" else "") @@ -334,13 +338,16 @@ class Installer: old_suffix = old_file.suffix old_file = old_file.rename(old_file.with_suffix(".bak")) proc = await self._hdiffpatch.patch_file(old_file, old_file.with_suffix(old_suffix), - patch_path) - await proc.wait() + patch_path, wait=True) patch_path.unlink() + if proc.returncode != 0: + # Let the game redownload the file. + old_file.rename(old_file.with_suffix(old_suffix)) + return old_file.unlink() - files.remove(patch_file) patch_jobs.append(extract_and_patch(current_game_file, patch_file)) + await asyncio.gather(*patch_jobs) deletefiles = archive.read("deletefiles.txt").decode().split("\n")