From: Samuel Kosmann <39554129+samuel-kosmann@users.noreply.github.com> Date: Sat, 24 May 2025 16:54:24 +0000 (+0200) Subject: add fallback to copyfile on PermissionError (#10023) X-Git-Tag: v2.16.2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aed629269d90cae24cc3ae7ee1bd401ffe12fa28;p=thirdparty%2Fpaperless-ngx.git add fallback to copyfile on PermissionError (#10023) Co-authored-by: Trenton H <797416+stumpylog@users.noreply.github.com> --- diff --git a/src/documents/utils.py b/src/documents/utils.py index d8a8e8ab2..e75194d82 100644 --- a/src/documents/utils.py +++ b/src/documents/utils.py @@ -40,10 +40,17 @@ def copy_file_with_basic_stats( The extended attribute copy does weird things with SELinux and files 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) - shutil.copy(source, dest) + try: + shutil.copy(source, dest) + except PermissionError: + shutil.copyfile(source, dest) + copy_basic_file_stats(source, dest)