feat: hdiff in voiceover update
This commit is contained in:
parent
089b799a5f
commit
820bc70e9d
2
setup.py
2
setup.py
@ -10,7 +10,7 @@ README = (HERE / "README.md").read_text()
|
||||
|
||||
setup(
|
||||
name='worthless',
|
||||
version='2.2.11',
|
||||
version='2.2.12',
|
||||
packages=['worthless', 'worthless.classes', 'worthless.classes.launcher', 'worthless.classes.installer'],
|
||||
url='https://git.froggi.es/tretrauit/worthless-launcher',
|
||||
license='MIT License',
|
||||
|
@ -3,3 +3,5 @@ from worthless import launcher, installer
|
||||
Launcher = launcher.Launcher
|
||||
Installer = installer.Installer
|
||||
|
||||
|
||||
__version__ = "2.2.12"
|
||||
|
@ -326,20 +326,14 @@ class Installer:
|
||||
voiceovers.append(file.name)
|
||||
return voiceovers
|
||||
|
||||
async def update_game(self, game_archive: str | Path | AsyncPath):
|
||||
if not await self.get_game_data_path().exists():
|
||||
raise FileNotFoundError(f"Game not found in {self._gamedir}")
|
||||
if isinstance(game_archive, str | Path):
|
||||
game_archive = Path(game_archive).resolve()
|
||||
if not game_archive.exists():
|
||||
raise FileNotFoundError(f"Update archive {game_archive} not found")
|
||||
|
||||
async def _update(self, game_archive: str | Path | AsyncPath):
|
||||
archive = zipfile.ZipFile(game_archive, 'r')
|
||||
|
||||
if not self._hdiffpatch.get_hpatchz_executable():
|
||||
await self._hdiffpatch.download_latest_release()
|
||||
|
||||
files = archive.namelist()
|
||||
|
||||
# Don't extract these files (they're useless and if the game isn't patched then it'll
|
||||
# raise 31-4xxx error ingame)
|
||||
for file in ["deletefiles.txt", "hdifffiles.txt"]:
|
||||
@ -349,6 +343,7 @@ class Installer:
|
||||
pass
|
||||
|
||||
# hdiffpatch implementation
|
||||
try:
|
||||
hdifffiles = []
|
||||
for x in (await asyncio.to_thread(archive.read, "hdifffiles.txt")).decode().split("\n"):
|
||||
if x:
|
||||
@ -389,7 +384,10 @@ class Installer:
|
||||
patch_jobs.append(extract_and_patch(current_game_file, patch_file))
|
||||
|
||||
await asyncio.gather(*patch_jobs)
|
||||
except Exception as e:
|
||||
print(f"Error while reading hdifffiles.txt: {e}")
|
||||
|
||||
try:
|
||||
deletefiles = archive.read("deletefiles.txt").decode().split("\n")
|
||||
for file in deletefiles:
|
||||
current_game_file = Path(self._gamedir.joinpath(file))
|
||||
@ -399,9 +397,21 @@ class Installer:
|
||||
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()
|
||||
|
||||
async def update_game(self, game_archive: str | Path | AsyncPath):
|
||||
if not await self.get_game_data_path().exists():
|
||||
raise FileNotFoundError(f"Game not found in {self._gamedir}")
|
||||
if isinstance(game_archive, str | Path):
|
||||
game_archive = Path(game_archive).resolve()
|
||||
if not game_archive.exists():
|
||||
raise FileNotFoundError(f"Update archive {game_archive} not found")
|
||||
|
||||
self._update(game_archive=game_archive)
|
||||
# Update game version on local variable.
|
||||
self._version = await self.get_game_version()
|
||||
self.set_version_config()
|
||||
@ -443,7 +453,10 @@ class Installer:
|
||||
# making this function universal for both cases
|
||||
if not await self.get_game_data_path().exists():
|
||||
raise FileNotFoundError(f"Game not found in {self._gamedir}")
|
||||
await self._extract_game_file(voiceover_archive)
|
||||
if isinstance(voiceover_archive, str | Path):
|
||||
voiceover_archive = Path(voiceover_archive).resolve()
|
||||
await self._update(voiceover_archive)
|
||||
# await self._extract_game_file(voiceover_archive)
|
||||
|
||||
async def install_game(self, game_archive: str | Path | AsyncPath, force_reinstall: bool = False):
|
||||
"""Installs the game to the current directory
|
||||
|
Loading…
Reference in New Issue
Block a user