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

This commit is contained in:
Trenton H
2025-01-14 15:18:10 -08:00
committed by GitHub
parent c45bbcaea2
commit 49a96ccee0

View 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}",