]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: do not try deleting original that was moved to trash dir (#9684)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Sat, 19 Apr 2025 22:11:29 +0000 (15:11 -0700)
committerGitHub <noreply@github.com>
Sat, 19 Apr 2025 22:11:29 +0000 (15:11 -0700)
src/documents/signals/handlers.py

index 16b3a01ea798ee82a5599b5e9f0b5ef0d772d925..673ecba5207ee88cae642a45894106b5fbb2fdb9 100644 (file)
@@ -349,11 +349,15 @@ def cleanup_document_deletion(sender, instance, **kwargs):
                 )
                 return
 
-        for filename in (
-            instance.source_path,
+        files = (
             instance.archive_path,
             instance.thumbnail_path,
-        ):
+        )
+        if not settings.EMPTY_TRASH_DIR:
+            # Only delete the original file if we are not moving it to trash dir
+            files += (instance.source_path,)
+
+        for filename in files:
             if filename and os.path.isfile(filename):
                 try:
                     os.unlink(filename)