From: Felix Eckhofer Date: Sun, 20 Feb 2022 13:04:43 +0000 (+0100) Subject: Catch exception during trash-move X-Git-Tag: ngx-1.6.0-rc1~67^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F24%2Fhead;p=thirdparty%2Fpaperless-ngx.git Catch exception during trash-move --- diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py index a86ee047f8..cf8b4fed26 100644 --- a/src/documents/signals/handlers.py +++ b/src/documents/signals/handlers.py @@ -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,