diff --git a/worthless/installer.py b/worthless/installer.py index ce220f5..2c5b8e3 100644 --- a/worthless/installer.py +++ b/worthless/installer.py @@ -343,6 +343,22 @@ class Installer: except ValueError: pass + try: + deletefiles = archive.read("deletefiles.txt").decode().split("\r\n") + for file in deletefiles: + current_game_file = Path(self._gamedir).joinpath(file) + if current_game_file == Path(self._gamedir): + # Don't delete the game folder + print("Game folder detected, not deleting:", current_game_file) + continue + if not current_game_file.relative_to(Path(self._gamedir)): + print("Not deleting (not relative to game):", current_game_file) + continue + print("Deleting", file) + current_game_file.unlink(missing_ok=True) + except Exception as e: + print(f"Error while reading deletefiles.txt: {e}") + # hdiffpatch implementation try: hdifffiles = [] @@ -403,22 +419,6 @@ class Installer: except Exception as e: print(f"Error while reading hdifffiles.txt: {e}") - try: - deletefiles = archive.read("deletefiles.txt").decode().split("\r\n") - for file in deletefiles: - current_game_file = Path(self._gamedir).joinpath(file) - if current_game_file == Path(self._gamedir): - # Don't delete the game folder - print("Game folder detected, not deleting:", current_game_file) - continue - if not current_game_file.relative_to(Path(self._gamedir)): - print("Not deleting (not relative to game):", current_game_file) - continue - print("Deleting", file) - current_game_file.unlink(missing_ok=True) - except Exception as e: - print(f"Error while reading deletefiles.txt: {e}") - await asyncio.to_thread(archive.extractall, self._gamedir, members=files) archive.close()