fix: handle FileExistsError
This commit is contained in:
parent
e3045f5150
commit
f54c2f432b
2
setup.py
2
setup.py
@ -9,7 +9,7 @@ README = (HERE / "README.md").read_text()
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='worthless',
|
name='worthless',
|
||||||
version='2.2.2',
|
version='2.2.3',
|
||||||
packages=['worthless', 'worthless.classes', 'worthless.classes.launcher', 'worthless.classes.installer'],
|
packages=['worthless', 'worthless.classes', 'worthless.classes.launcher', 'worthless.classes.installer'],
|
||||||
url='https://git.froggi.es/tretrauit/worthless-launcher',
|
url='https://git.froggi.es/tretrauit/worthless-launcher',
|
||||||
license='MIT License',
|
license='MIT License',
|
||||||
|
@ -336,6 +336,9 @@ async def main():
|
|||||||
if args.from_ver:
|
if args.from_ver:
|
||||||
ui.override_game_version(args.from_ver)
|
ui.override_game_version(args.from_ver)
|
||||||
|
|
||||||
|
if args.from_vo_ver:
|
||||||
|
ui.override_voiceover_version(args.from_ver)
|
||||||
|
|
||||||
if args.get_game_version:
|
if args.get_game_version:
|
||||||
await ui.get_game_version()
|
await ui.get_game_version()
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class HDiffPatch:
|
|||||||
data_dir = Path(data_dir)
|
data_dir = Path(data_dir)
|
||||||
self.data_path = Path(data_dir).joinpath("Tools/HDiffPatch")
|
self.data_path = Path(data_dir).joinpath("Tools/HDiffPatch")
|
||||||
self.temp_path = data_dir.joinpath("Temp/HDiffPatch")
|
self.temp_path = data_dir.joinpath("Temp/HDiffPatch")
|
||||||
self.temp_path.mkdir(parents=True, exist_ok=True)
|
Path(self.temp_path).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_platform_arch():
|
def _get_platform_arch():
|
||||||
@ -350,14 +350,18 @@ class Installer:
|
|||||||
async def extract_and_patch(old_file, diff_file):
|
async def extract_and_patch(old_file, diff_file):
|
||||||
diff_path = self.temp_path.joinpath(diff_file)
|
diff_path = self.temp_path.joinpath(diff_file)
|
||||||
if diff_path.is_file():
|
if diff_path.is_file():
|
||||||
await diff_path.unlink(missing_ok=True)
|
diff_path.unlink(missing_ok=True)
|
||||||
|
try:
|
||||||
|
print(diff_file)
|
||||||
await asyncio.to_thread(archive.extract, diff_file, self.temp_path)
|
await asyncio.to_thread(archive.extract, diff_file, self.temp_path)
|
||||||
|
except FileExistsError:
|
||||||
|
pass
|
||||||
patch_path = self.temp_path.joinpath(diff_file)
|
patch_path = self.temp_path.joinpath(diff_file)
|
||||||
old_suffix = old_file.suffix
|
old_suffix = old_file.suffix
|
||||||
old_file = await old_file.rename(old_file.with_suffix(".bak"))
|
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),
|
proc = await self._hdiffpatch.patch_file(old_file, old_file.with_suffix(old_suffix),
|
||||||
patch_path, wait=True)
|
patch_path, wait=True)
|
||||||
await patch_path.unlink()
|
patch_path.unlink()
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
# Let the game download the file.
|
# Let the game download the file.
|
||||||
await old_file.rename(old_file.with_suffix(old_suffix))
|
await old_file.rename(old_file.with_suffix(old_suffix))
|
||||||
|
Loading…
Reference in New Issue
Block a user