]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Catch exception during trash-move 24/head
authorFelix Eckhofer <felix@eckhofer.com>
Sun, 20 Feb 2022 13:04:43 +0000 (14:04 +0100)
committerFelix Eckhofer <felix@eckhofer.com>
Sun, 20 Feb 2022 13:17:13 +0000 (14:17 +0100)
src/documents/signals/handlers.py

index a86ee047f855f1dda0b84f995a588b08f9639259..cf8b4fed2672e19b0400a59ca2394cfaa71c4ec5 100644 (file)
@@ -247,7 +247,14 @@ def cleanup_document_deletion(sender, instance, using, **kwargs):
 
             logger.debug(
                 f"Moving {instance.source_path} to trash at {new_file_path}")
-            os.rename(instance.source_path, new_file_path)
+            try:
+                os.rename(instance.source_path, new_file_path)
+            except OSError as e:
+                logger.error(
+                    f"Failed to move {instance.source_path} to trash at "
+                    f"{new_file_path}: {e}. Skipping cleanup!"
+                )
+                return
 
         for filename in (instance.source_path,
                          instance.archive_path,