Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit: Fix dpkg version cache #343

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions github_app_geo_project/module/audit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
Loading