diff --git a/worthless/installer.py b/worthless/installer.py index 986e775..f2c9ed4 100644 --- a/worthless/installer.py +++ b/worthless/installer.py @@ -361,16 +361,14 @@ class Installer: patch_file = str(file) + ".hdiff" async def extract_and_patch(old_file, diff_file): - diff_path = self.temp_path.joinpath(diff_file) - if diff_path.is_file(): - diff_path.unlink(missing_ok=True) + patch_path = self.temp_path.joinpath(diff_file) + patch_path.unlink(missing_ok=True) try: print(diff_file) await asyncio.to_thread(archive.extract, diff_file, self.temp_path) except FileExistsError: print("Failed to extract diff file", diff_file) return - patch_path = self.temp_path.joinpath(diff_file) old_suffix = old_file.suffix old_file = await old_file.rename(old_file.with_suffix(".bak")) proc = await self._hdiffpatch.patch_file(old_file, old_file.with_suffix(old_suffix), @@ -378,6 +376,9 @@ class Installer: patch_path.unlink() if proc.returncode != 0: # Let the game download the file. + print("Failed to patch {}, reverting and let the in-game updater do the job...".format( + old_file.with_suffix(old_suffix)) + ) await old_file.rename(old_file.with_suffix(old_suffix)) return await old_file.unlink()