repo.py: drop deleted packages from provider cache (#43779)
The reverse provider lookup may have stale entries for deleted packages, which used to cause errors. It's hard to invalidate those cache entries, so this commit simply drops entries w/o invalidating the cache. Co-authored-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
parent
e1f2612581
commit
d6baae525f
1 changed files with 10 additions and 6 deletions
|
@ -726,14 +726,14 @@ def first_repo(self):
|
|||
"""Get the first repo in precedence order."""
|
||||
return self.repos[0] if self.repos else None
|
||||
|
||||
@llnl.util.lang.memoized
|
||||
def _all_package_names_set(self, include_virtuals):
|
||||
return {name for repo in self.repos for name in repo.all_package_names(include_virtuals)}
|
||||
|
||||
@llnl.util.lang.memoized
|
||||
def _all_package_names(self, include_virtuals):
|
||||
"""Return all unique package names in all repositories."""
|
||||
all_pkgs = set()
|
||||
for repo in self.repos:
|
||||
for name in repo.all_package_names(include_virtuals):
|
||||
all_pkgs.add(name)
|
||||
return sorted(all_pkgs, key=lambda n: n.lower())
|
||||
return sorted(self._all_package_names_set(include_virtuals), key=lambda n: n.lower())
|
||||
|
||||
def all_package_names(self, include_virtuals=False):
|
||||
return self._all_package_names(include_virtuals)
|
||||
|
@ -794,7 +794,11 @@ def patch_index(self):
|
|||
|
||||
@autospec
|
||||
def providers_for(self, vpkg_spec):
|
||||
providers = self.provider_index.providers_for(vpkg_spec)
|
||||
providers = [
|
||||
spec
|
||||
for spec in self.provider_index.providers_for(vpkg_spec)
|
||||
if spec.name in self._all_package_names_set(include_virtuals=False)
|
||||
]
|
||||
if not providers:
|
||||
raise UnknownPackageError(vpkg_spec.fullname)
|
||||
return providers
|
||||
|
|
Loading…
Reference in a new issue