diff options
author | Harmen Stoppels <me@harmenstoppels.nl> | 2024-04-22 19:03:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-22 19:03:44 +0200 |
commit | d6baae525fd3a0ace512f6ffd56b907d8802810c (patch) | |
tree | e9812fa1cbac4b5e5482cddbd030c59e0e21a1a1 /lib | |
parent | e1f26125814bdce4724cdee0dc4687bce81370d2 (diff) | |
download | spack-d6baae525fd3a0ace512f6ffd56b907d8802810c.tar.gz spack-d6baae525fd3a0ace512f6ffd56b907d8802810c.tar.bz2 spack-d6baae525fd3a0ace512f6ffd56b907d8802810c.tar.xz spack-d6baae525fd3a0ace512f6ffd56b907d8802810c.zip |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/repo.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/spack/spack/repo.py b/lib/spack/spack/repo.py index b5f7640baf..9b6f104fe5 100644 --- a/lib/spack/spack/repo.py +++ b/lib/spack/spack/repo.py @@ -727,13 +727,13 @@ class RepoPath: 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 @@ class RepoPath: @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 |