avoid fs in repo.exists

This commit is contained in:
Harmen Stoppels 2024-08-23 14:45:45 +02:00
parent 225a4ed1ff
commit dc3e124d1d

View File

@ -1261,16 +1261,7 @@ def all_package_classes(self) -> Generator[Type["spack.package_base.PackageBase"
def exists(self, pkg_name: str) -> bool:
"""Whether a package with the supplied name exists."""
if pkg_name is None:
return False
# if the FastPackageChecker is already constructed, use it
if self._fast_package_checker:
return pkg_name in self._pkg_checker
# if not, check for the package.py file
path = self.filename_for_package_name(pkg_name)
return os.path.exists(path)
return pkg_name is not None and pkg_name in self._pkg_checker
def last_mtime(self):
"""Time a package file in this repo was last updated."""