Lock the media directory and refresh the document to ensure we have where it actually lives before attaching ()

This commit is contained in:
Trenton H 2025-01-14 15:18:10 -08:00 committed by GitHub
parent c45bbcaea2
commit 49a96ccee0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -943,7 +943,10 @@ def run_workflows(
to=action.email.to.split(","), to=action.email.to.split(","),
) )
if action.email.include_document: 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() n_messages = email.send()
logger.debug( logger.debug(
f"Sent {n_messages} notification email(s) to {action.email.to}", f"Sent {n_messages} notification email(s) to {action.email.to}",