From ae8d85e9cd4aef6dde875a779253fceb231d6339 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Jul 28 2023 10:52:42 +0000 Subject: Don’t use cached values for changes spec file Fixes: #299 Signed-off-by: Nils Philippsen --- diff --git a/rpmautospec/misc.py b/rpmautospec/misc.py index ee28ab6..3b716c4 100644 --- a/rpmautospec/misc.py +++ b/rpmautospec/misc.py @@ -24,11 +24,8 @@ class FileIsModifiedError(OSError): pass -@lru_cache(maxsize=None) -def check_specfile_features(specpath: Union[Path, str]) -> SpecfileFeatures: - if not isinstance(specpath, Path): - specpath = Path(specpath) - +@lru_cache(maxsize=1024) +def _check_specfile_features(specpath: Path, mtime: float, size: int) -> SpecfileFeatures: has_autorelease = False changelog_lineno = None autochangelog_lineno = None @@ -55,6 +52,14 @@ def check_specfile_features(specpath: Union[Path, str]) -> SpecfileFeatures: ) +def check_specfile_features(specpath: Union[Path, str]) -> SpecfileFeatures: + if not isinstance(specpath, Path): + specpath = Path(specpath).resolve() + + stat_result = specpath.stat() + return _check_specfile_features(specpath, stat_result.st_mtime, stat_result.st_size) + + def specfile_uses_rpmautospec( specpath: Union[Path, str], check_autorelease: bool = True, check_autochangelog: bool = True ) -> bool: