From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Tue, 14 Jan 2025 23:18:10 +0000 (-0800) Subject: Lock the media directory and refresh the document to ensure we have where it actually... X-Git-Tag: v2.14.2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49a96ccee0be824613d6be7d342af47604d05fdc;p=thirdparty%2Fpaperless-ngx.git Lock the media directory and refresh the document to ensure we have where it actually lives before attaching (#8737) --- diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py index d3fa11b3b1..c836f4d1ee 100644 --- a/src/documents/signals/handlers.py +++ b/src/documents/signals/handlers.py @@ -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}",