From 54b0630891cfc68273ab7529dcdbd252166ba48e Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Sun, 18 Feb 2024 21:57:51 -0800 Subject: [PATCH] Allow 7z for rar decompression on Windows --- comicapi/archivers/rar.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/comicapi/archivers/rar.py b/comicapi/archivers/rar.py index 5a1afd0..4628bb5 100644 --- a/comicapi/archivers/rar.py +++ b/comicapi/archivers/rar.py @@ -289,13 +289,17 @@ class RarArchiver(Archiver): orig = rarfile.UNRAR_TOOL rarfile.UNRAR_TOOL = cls.exe try: - return rarfile.is_rarfile(str(path)) and rarfile.tool_setup(sevenzip=False, sevenzip2=False, force=True) + return rarfile.is_rarfile(str(path)) and rarfile.tool_setup( + sevenzip=platform.system() == "Windows", sevenzip2=platform.system() == "Windows", force=True + ) except rarfile.RarCannotExec: rarfile.UNRAR_TOOL = orig # Fallback to standard try: - return rarfile.is_rarfile(str(path)) and rarfile.tool_setup(sevenzip=False, sevenzip2=False, force=True) + return rarfile.is_rarfile(str(path)) and rarfile.tool_setup( + sevenzip=platform.system() == "Windows", sevenzip2=platform.system() == "Windows", force=True + ) except rarfile.RarCannotExec as e: logger.info(e) return False