]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: Add exception to `utime` in `copy_basic_file_stats` (#10070)
authorFreilichtbühne <52177341+Freilichtbuehne@users.noreply.github.com>
Wed, 28 May 2025 22:13:03 +0000 (00:13 +0200)
committerGitHub <noreply@github.com>
Wed, 28 May 2025 22:13:03 +0000 (15:13 -0700)
src/documents/utils.py

index e75194d82a16fcdc83ada99d1afd9b3823098087..04aa95bce657b2c04423ebeb7933f935a3d53cce 100644 (file)
@@ -23,11 +23,17 @@ def copy_basic_file_stats(source: Path | str, dest: Path | str) -> None:
 
     The extended attribute copy does weird things with SELinux and files
     copied from temporary directories and copystat doesn't allow disabling
-    these copies
+    these copies.
+
+    If there is a PermissionError, skip copying file stats.
     """
     source, dest = _coerce_to_path(source, dest)
     src_stat = source.stat()
-    utime(dest, ns=(src_stat.st_atime_ns, src_stat.st_mtime_ns))
+
+    try:
+        utime(dest, ns=(src_stat.st_atime_ns, src_stat.st_mtime_ns))
+    except PermissionError:
+        pass
 
 
 def copy_file_with_basic_stats(