cmds.secrets.lib.DistroContext: Batch file listing code

The compile phase of a secrets deploy makes one SSH round-trip per package
to list the package files. On a host with nine packages, that is nine
round-trips.

Make match_files() pass the whole name list to pkg_paths() in one call: the
distro backends already accept a list and issue a single file-listing
command.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.2
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-11-19 14:37:31 +01:00
commit 65e55a1119
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -33,11 +33,12 @@ class DistroContext(FilesContext):
self.__distro = distro
async def match_files(self, pkg_names: Collection[str], pattern: str) -> list[str]:
# -- One query for the whole name list: the distro backends
# accept a list and issue a single file-listing command
ret: list[str] = []
for pkg_name in pkg_names:
for path in await self.__distro.pkg_paths(pkg_name):
if re.match(pattern, path):
ret.append(path)
for path in await self.__distro.pkg_paths(list(pkg_names)):
if re.match(pattern, path):
ret.append(path)
return ret
async def list_template_files(self, pkg_names: Collection[str]) -> list[str]: