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:
parent
0ca539dc0f
commit
fe3060eee6
1 changed files with 6 additions and 4 deletions
|
|
@ -204,7 +204,9 @@ async def copy(
|
||||||
s_path = f'{src_path}/{dirent}' if src_path else dirent
|
s_path = f'{src_path}/{dirent}' if src_path else dirent
|
||||||
d_path = f'{dst_path}/{dirent}' if dst_path else dirent
|
d_path = f'{dst_path}/{dirent}' if dst_path else dirent
|
||||||
s_st = await ctx.src.stat(s_path)
|
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))
|
ret.extend(await __copy_tree(s_path, d_path))
|
||||||
continue
|
continue
|
||||||
result = await ctx.src.get(s_path, throw = True)
|
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):
|
if basename and await ctx.dst.is_dir(ret):
|
||||||
ret += '/' + basename
|
ret += '/' + basename
|
||||||
src_root = '' if ctx.src.chroot else ctx.src.root
|
src_root = '' if ctx.src.chroot else ctx.src.root
|
||||||
|
s_st = await ctx.src.stat(src_root)
|
||||||
if recursive and await ctx.src.is_dir(src_root):
|
if recursive and s_st.is_dir and not s_st.is_gettable:
|
||||||
return await __copy_tree(src_root, ret)
|
return await __copy_tree(src_root, ret)
|
||||||
|
|
||||||
result = await ctx.src.get(src_root, throw = True)
|
result = await ctx.src.get(src_root, throw = True)
|
||||||
|
|
@ -267,7 +269,7 @@ async def copy(
|
||||||
owner = owner,
|
owner = owner,
|
||||||
group = group,
|
group = group,
|
||||||
mode = mode,
|
mode = mode,
|
||||||
ftype = (await ctx.src.stat(src_root)).ftype,
|
ftype = s_st.ftype,
|
||||||
throw = True,
|
throw = True,
|
||||||
)
|
)
|
||||||
return ret
|
return ret
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue