From efc2abf85842f498b931e454aceb5ef92f4fed26 Mon Sep 17 00:00:00 2001 From: tretrauit Date: Mon, 27 Jun 2022 04:09:47 +0700 Subject: [PATCH] feat: add -Swp option perf: tar.extractall wrapped in asyncio.to_thread --- setup.py | 2 +- worthless/cli.py | 5 +++++ worthless/patcher.py | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index c672fa9..d931cfc 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ README = (HERE / "README.md").read_text() setup( name='worthless', - version='2.1.0', + version='2.1.0-1', packages=['worthless', 'worthless.classes', 'worthless.classes.launcher', 'worthless.classes.installer'], url='https://git.froggi.es/tretrauit/worthless-launcher', license='MIT License', diff --git a/worthless/cli.py b/worthless/cli.py index 6ced00b..96b7406 100755 --- a/worthless/cli.py +++ b/worthless/cli.py @@ -274,6 +274,8 @@ async def main(): help="Update the game and specified voiceover pack only (or install if not found)") parser.add_argument("-Sw", "--download-game", action="store_true", help="Download the full game to the temporary directory") + parser.add_argument("-Swp", "--download-patch", action="store_true", + help="Download/Update the game patch to the temporary directory") parser.add_argument("-Swv", "--download-voiceover", action="store", type=str, help="Download the full voiceover to the temporary directory") parser.add_argument("-Syw", "--download-game-update", action="store", type=str, default="", @@ -330,6 +332,9 @@ async def main(): if args.download_game: await ui.download_game() + if args.download_patch: + await ui.download_patch() + if args.download_voiceover: await ui.download_voiceover(args.download_voiceover) diff --git a/worthless/patcher.py b/worthless/patcher.py index dbe3267..e534234 100644 --- a/worthless/patcher.py +++ b/worthless/patcher.py @@ -95,8 +95,8 @@ class Patcher: if not archive: raise RuntimeError("Cannot download patch repository") - with tarfile.open(archive) as tar: - tar.extractall(self._patch_path) + async with tarfile.open(archive) as tar: + await asyncio.to_thread(tar.extractall, self._patch_path) def override_patch_url(self, url) -> None: """