From 1863fafd85f01f05703bf0008ad59c8e082cf8e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=E1=BA=BF=20H=C6=B0ng?= Date: Wed, 26 Feb 2025 18:48:46 +0700 Subject: [PATCH] fix(common): manually close the merged archive --- vollerei/common/functions.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vollerei/common/functions.py b/vollerei/common/functions.py index b3c6561..7d2d8b8 100644 --- a/vollerei/common/functions.py +++ b/vollerei/common/functions.py @@ -226,15 +226,18 @@ def install_archive(game: GameABC, archive_file: Path | IOBase) -> None: """ archive: py7zr.SevenZipFile | zipfile.ZipFile = None archive_path = Path(archive_file) + target_archive = None if archive_path.suffix == ".001": archive_path = archive_path.with_suffix("") - with multivolumefile.open(archive_path, mode='rb') as target_archive: - # TODO: Implement for .zip file (but I doubt it's needed cuz miHoYo uses 7z) - archive = py7zr.SevenZipFile(target_archive, "r") + target_archive = multivolumefile.open(archive_path, mode='rb') + # TODO: Implement for .zip file (but I doubt it's needed cuz miHoYo uses 7z) + archive = py7zr.SevenZipFile(target_archive, "r") else: archive = _open_archive(archive_file) archive.extractall(game.path) archive.close() + if target_archive: + target_archive.close() def _repair_file(game: GameABC, file: PathLike, game_info: resource.Main) -> None: