fix: actually delete files in deletefiles.txt

This commit is contained in:
2023-05-25 13:01:04 +07:00
parent aa4fe4d5ed
commit 973ae2a5e6
5 changed files with 9 additions and 6 deletions

View File

@ -404,14 +404,17 @@ class Installer:
print(f"Error while reading hdifffiles.txt: {e}")
try:
deletefiles = archive.read("deletefiles.txt").decode().split("\n")
deletefiles = archive.read("deletefiles.txt").decode().split("\r\n")
for file in deletefiles:
current_game_file = Path(self._gamedir.joinpath(file))
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.is_file():
if not current_game_file.relative_to(Path(self._gamedir)):
print("Not deleting (not relative to game):", current_game_file)
continue
print("Deleting ", file)
print("Deleting", file)
current_game_file.unlink(missing_ok=True)
except Exception as e:
print(f"Error while reading deletefiles.txt: {e}")