fix(dist): stop USER_OWNED_EXCLUDE from filtering nested directories
The copytree ignore lambda in _copy_dist_payload applied USER_OWNED_EXCLUDE recursively at every directory depth. This caused nested directories whose names matched exclude entries (bin, logs, cache, etc.) to be silently dropped during distribution install/update. Fix: only apply USER_OWNED_EXCLUDE filtering at the root of the staged tree, matching the two-tier pattern used by _clone_all_copytree_ignore and _default_export_ignore in profiles.py. Add 5 tests covering nested bin/logs/cache preservation and top-level filtering still working. Fixes #37954
This commit is contained in:
@@ -573,10 +573,15 @@ def _copy_dist_payload(
|
||||
if entry.is_dir():
|
||||
if dest.exists():
|
||||
shutil.rmtree(dest)
|
||||
staged_resolved = staged.resolve()
|
||||
shutil.copytree(
|
||||
entry,
|
||||
dest,
|
||||
ignore=lambda d, names: [n for n in names if n in USER_OWNED_EXCLUDE],
|
||||
ignore=lambda d, names: (
|
||||
[n for n in names if n in USER_OWNED_EXCLUDE]
|
||||
if Path(d).resolve() == staged_resolved
|
||||
else []
|
||||
),
|
||||
)
|
||||
else:
|
||||
shutil.copy2(entry, dest)
|
||||
|
||||
Reference in New Issue
Block a user