updater: remove directory in deletefiles.txt too

This commit is contained in:
2022-11-02 12:26:37 +07:00
parent abdf19bc16
commit 0b51be1649
2 changed files with 4 additions and 9 deletions

View File

@ -391,6 +391,9 @@ class Installer:
continue
if current_game_file.is_file():
current_game_file.unlink(missing_ok=True)
continue
if current_game_file.is_dir():
shutil.rmtree(current_game_file, ignore_errors=True)
await asyncio.to_thread(archive.extractall, self._gamedir, members=files)
archive.close()
@ -426,14 +429,6 @@ class Installer:
archive = Path(archive).resolve()
if not archive.exists():
raise FileNotFoundError(f"'{archive}' not found")
# game_dir_str = str(self._gamedir)
# if not game_dir_str.endswith("/"):
# game_dir_str += "/"
# print(f'-o"{game_dir_str}"')
# proc = await asyncio.create_subprocess_shell(f'7z x {str(archive)} -o"{game_dir_str}"')
# await proc.wait()
# if proc.returncode != 0:
# raise RuntimeError("Extracting failed")
with zipfile.ZipFile(archive, 'r') as f:
await asyncio.to_thread(f.extractall, path=self._gamedir)