From 3b5e9d8f95621533e9544558a919fa6c2a54a9cc Mon Sep 17 00:00:00 2001 From: Timmy Welch <timmy@narnian.us> Date: Tue, 18 Mar 2025 21:25:04 -0700 Subject: [PATCH] Log a warning the first time we can't find rar for writing --- comicapi/archivers/rar.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/comicapi/archivers/rar.py b/comicapi/archivers/rar.py index d3d1a0e..ba03b1b 100644 --- a/comicapi/archivers/rar.py +++ b/comicapi/archivers/rar.py @@ -1,5 +1,6 @@ from __future__ import annotations +import functools import logging import os import pathlib @@ -271,10 +272,16 @@ class RarArchiver(Archiver): else: return True + @classmethod + @functools.cache + def _log_not_writeable(cls, exe: str) -> None: + logger.warning("Unable to find a useable copy of %r, will not be able to write rar files", str) + def is_writable(self) -> bool: + writeable = False try: if bool(self.exe and (os.path.exists(self.exe) or shutil.which(self.exe))): - return ( + writeable = ( subprocess.run( (self.exe,), startupinfo=self.startupinfo, @@ -286,6 +293,8 @@ class RarArchiver(Archiver): ) except OSError: ... + if not writeable: + self._log_not_writeable(self.exe or "rar") return False def extension(self) -> str: