add fallback to copyfile on PermissionError (#10023)

Co-authored-by: Trenton H <797416+stumpylog@users.noreply.github.com>
This commit is contained in:
Samuel Kosmann
2025-05-24 18:54:24 +02:00
committed by GitHub
parent 59bf25edb1
commit aed629269d

View File

@@ -40,10 +40,17 @@ def copy_file_with_basic_stats(
The extended attribute copy does weird things with SELinux and files The extended attribute copy does weird things with SELinux and files
copied from temporary directories. copied from temporary directories.
If there is a PermissionError (e.g., on ZFS with acltype=nfsv4)
fall back to copyfile (data only).
""" """
source, dest = _coerce_to_path(source, dest) source, dest = _coerce_to_path(source, dest)
try:
shutil.copy(source, dest) shutil.copy(source, dest)
except PermissionError:
shutil.copyfile(source, dest)
copy_basic_file_stats(source, dest) copy_basic_file_stats(source, dest)