lib.util.copy(): Support FileContext source, file types, and --parents #144

Merged
Jan Lindemann merged 8 commits from jan/feature/20261017-lib-util-copy-support-filecontext-source-file-types-and-parents into master 2026-10-17 11:57:05 +02:00 AGit
Showing only changes of commit ca04128a37 - Show all commits

lib.util.copy(): Copy file types

The file type framework gives mkdir() and put() an ftype argument, but
copy() calls them untyped, so the source's node types are discarded at the
landing: a destination that applies its own node types receives only the
defaults.

This commit threads the source's types through.

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.1.0
Jan Lindemann 2026-10-04 14:15:45 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -198,7 +198,7 @@ async def copy(
ret: list[str] = []
s_st = await ctx.src.stat(src_path)
if dst_path and not await ctx.dst.is_dir(dst_path):
await ctx.dst.mkdir(dst_path)
await ctx.dst.mkdir(dst_path, ftype = s_st.ftype)
for dirent in await ctx.src.readdir(src_path):
s_path = f'{src_path}/{dirent}' if src_path else dirent
d_path = f'{dst_path}/{dirent}' if dst_path else dirent
@ -213,6 +213,7 @@ async def copy(
owner = owner,
group = group,
mode = mode,
ftype = s_st.ftype,
throw = True,
)
ret.append(d_path)
@ -242,6 +243,7 @@ async def copy(
owner = owner,
group = group,
mode = mode,
ftype = (await ctx.src.stat(src_root)).ftype,
throw = True,
)
return ret