From 7fd7dd4ff96f2948534270aa600f864d747b2b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Sat, 8 Jun 2024 17:18:53 +0200 Subject: [PATCH] Audit: Fix dpkg version cache --- github_app_geo_project/module/audit/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/github_app_geo_project/module/audit/utils.py b/github_app_geo_project/module/audit/utils.py index ee9f3ca01de..dce806e6f25 100644 --- a/github_app_geo_project/module/audit/utils.py +++ b/github_app_geo_project/module/audit/utils.py @@ -408,7 +408,8 @@ def _get_sources( _PACKAGE_VERSION[name] = version except ValueError as exception: _LOGGER.warning( - "Error while parsing the package %s version of %s: %s", + "Error while parsing the package %s/%s version of %s: %s", + dist, package.package, package.version, exception, @@ -421,12 +422,13 @@ async def _get_packages_version( package: str, config: configuration.DpkgConfiguration, local_config: configuration.DpkgConfiguration ) -> str | None: """Get the version of the package.""" + global _GENERATION_TIME # pylint: disable=global-statement if _GENERATION_TIME is None or _GENERATION_TIME < datetime.datetime.now() - utils.parse_duration( os.environ.get("GHCI_DPKG_CACHE_DURATION", "3h") ): _PACKAGE_VERSION.clear() _SOURCES.clear() - datetime.datetime.now() + _GENERATION_TIME = datetime.datetime.now() if package not in _PACKAGE_VERSION: dist = package.split("/")[0] await asyncio.to_thread(_get_sources, dist, config, local_config)