[PR jw/#169] lib.util.copy(): Require recursive for directories
All checks were successful
CI / Packaging - Kali Linux (push) Successful in 4m49s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 5m0s
CI / Packaging test (push) Successful in 0s

Merge pull request "lib.util.copy(): Require recursive for directories"

Upstream-repo: ssh://git@code.janware.com/janware/jw-pkg
Source-branch: jan/feature/20261107-lib-util-copy-require-recursive-for-directories
Target-branch: master
Reviewed-on: #169
This commit is contained in:
Jan Lindemann 2026-11-07 14:35:41 +01:00 • committed by janware Code
commit bed3e90169
Signed by: Code Bot
GPG key ID: 66A5D2B295EE1224

View file

@ -259,7 +259,13 @@ async def copy(
ret += '/' + basename
src_root = '' if ctx.src.chroot else ctx.src.root
s_st = await ctx.src.stat(src_root)
if recursive and s_st.is_dir and not s_st.is_gettable:
if s_st.is_dir and not s_st.is_gettable:
# -- A directory is not a single fetchable object,
# and cp copies directories only with -r
if not recursive:
raise Exception(
f'Copying directory "{src}" requires recursive=True'
)
return await __copy_tree(src_root, ret)
result = await ctx.src.get(src_root, throw = True)