lib.util.copy(): Support FileContext source, file types, and --parents #144
1 changed files with 6 additions and 4 deletions
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>
commit
fe3060eee6
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue