]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
add fallback to copyfile on PermissionError (#10023)
authorSamuel Kosmann <39554129+samuel-kosmann@users.noreply.github.com>
Sat, 24 May 2025 16:54:24 +0000 (18:54 +0200)
committerGitHub <noreply@github.com>
Sat, 24 May 2025 16:54:24 +0000 (16:54 +0000)
Co-authored-by: Trenton H <797416+stumpylog@users.noreply.github.com>
src/documents/utils.py

index d8a8e8ab20e45e65e0ba01ebbdf4b85d859b793d..e75194d82a16fcdc83ada99d1afd9b3823098087 100644 (file)
@@ -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)