lib.util.copy(): Terminate the walk at compound nodes

The walk needlessly descends into every directory node: A compound node is
gettable as a whole, so copy it over and don't recurse deeper.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-10-04 18:53:57 +02:00
commit fe3060eee6
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -204,7 +204,9 @@ async def copy(
s_path = f'{src_path}/{dirent}' if src_path else dirent
d_path = f'{dst_path}/{dirent}' if dst_path else dirent
s_st = await ctx.src.stat(s_path)
if s_st.is_dir:
# -- Descend into directories that are not fetchable
# whole; an entry, which is both, lands as a file
if s_st.is_dir and not s_st.is_gettable:
ret.extend(await __copy_tree(s_path, d_path))
continue
result = await ctx.src.get(s_path, throw = True)
@ -256,8 +258,8 @@ async def copy(
if basename and await ctx.dst.is_dir(ret):
ret += '/' + basename
src_root = '' if ctx.src.chroot else ctx.src.root
if recursive and await ctx.src.is_dir(src_root):
s_st = await ctx.src.stat(src_root)
if recursive and s_st.is_dir and not s_st.is_gettable:
return await __copy_tree(src_root, ret)
result = await ctx.src.get(src_root, throw = True)
@ -267,7 +269,7 @@ async def copy(
owner = owner,
group = group,
mode = mode,
ftype = (await ctx.src.stat(src_root)).ftype,
ftype = s_st.ftype,
throw = True,
)
return ret