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
This commit is contained in:
parent
a328b01e9a
commit
ca04128a37
1 changed files with 3 additions and 1 deletions
|
|
@ -198,7 +198,7 @@ async def copy(
|
||||||
ret: list[str] = []
|
ret: list[str] = []
|
||||||
s_st = await ctx.src.stat(src_path)
|
s_st = await ctx.src.stat(src_path)
|
||||||
if dst_path and not await ctx.dst.is_dir(dst_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):
|
for dirent in await ctx.src.readdir(src_path):
|
||||||
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
|
||||||
|
|
@ -213,6 +213,7 @@ async def copy(
|
||||||
owner = owner,
|
owner = owner,
|
||||||
group = group,
|
group = group,
|
||||||
mode = mode,
|
mode = mode,
|
||||||
|
ftype = s_st.ftype,
|
||||||
throw = True,
|
throw = True,
|
||||||
)
|
)
|
||||||
ret.append(d_path)
|
ret.append(d_path)
|
||||||
|
|
@ -242,6 +243,7 @@ async def copy(
|
||||||
owner = owner,
|
owner = owner,
|
||||||
group = group,
|
group = group,
|
||||||
mode = mode,
|
mode = mode,
|
||||||
|
ftype = (await ctx.src.stat(src_root)).ftype,
|
||||||
throw = True,
|
throw = True,
|
||||||
)
|
)
|
||||||
return ret
|
return ret
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue