pf.Pkg._access(): Use Distro.paths()

Distro.paths() now allows to spare a detour in Pkg._access() - we can
directly get to the list of paths instead of via Distro.select() ->
pkg_paths().

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-11-12 16:03:58 +01:00
commit ea751d3949
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61
2 changed files with 13 additions and 2 deletions

View file

@ -65,8 +65,9 @@ class PackageFilter(FileContextFilter): # export
async def _access(self, path: str, mode: int = os.F_OK) -> bool:
if self.__space is None:
distro = await self.distro()
names = [p.name for p in await distro.select([], filter = self)]
self.__space = set(self.__add_parent_paths(await distro.pkg_paths(names)))
self.__space = set(
self.__add_parent_paths(await distro.paths(filter = self))
)
return path in self.__space
class Pkg(PackageFilter): # export

View file

@ -92,6 +92,16 @@ class _FakeDistro:
ret.extend(files)
return ret
async def paths(self, filter: Any = None, pkg_names: Any = []) -> list[str]:
ret: list[str] = []
for p, files in self.__pkgs:
if filter is not None and not filter.match_pkg(p):
continue
if pkg_names and p.name not in pkg_names:
continue
ret.extend(files)
return ret
fake = _FakeDistro(
[
(