]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Lock the media directory and refresh the document to ensure we have where it actually...
authorTrenton H <797416+stumpylog@users.noreply.github.com>
Tue, 14 Jan 2025 23:18:10 +0000 (15:18 -0800)
committerGitHub <noreply@github.com>
Tue, 14 Jan 2025 23:18:10 +0000 (23:18 +0000)
src/documents/signals/handlers.py

index d3fa11b3b1d67ae6285ffe8451bca4023c9c47fa..c836f4d1ee964195a28c9bf263dd2433fadfbf3a 100644 (file)
@@ -943,7 +943,10 @@ def run_workflows(
                 to=action.email.to.split(","),
             )
             if action.email.include_document:
-                email.attach_file(document.source_path)
+                # Something could be renaming the file concurrently so it can't be attached
+                with FileLock(settings.MEDIA_LOCK):
+                    document.refresh_from_db()
+                    email.attach_file(document.source_path)
             n_messages = email.send()
             logger.debug(
                 f"Sent {n_messages} notification email(s) to {action.email.to}",