From f68ee628d9e2d6fbc8a9b8c975da8eadeaeec794 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 15 Jan 2025 22:13:40 -0800 Subject: [PATCH] Refactor: consolidate original_file logic in wf handler --- src/documents/signals/handlers.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py index 7fa714f10..fd17bbf74 100644 --- a/src/documents/signals/handlers.py +++ b/src/documents/signals/handlers.py @@ -981,11 +981,7 @@ def run_workflows( # 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( - original_file - if original_file is not None - else document.source_path, - ) + email.attach_file(original_file) n_messages = email.send() logger.debug( f"Sent {n_messages} notification email(s) to {action.email.to}", @@ -1085,9 +1081,7 @@ def run_workflows( files = None if action.webhook.include_document: with open( - original_file - if original_file is not None - else document.source_path, + original_file, "rb", ) as f: files = { @@ -1114,6 +1108,10 @@ def run_workflows( ) use_overrides = overrides is not None + if original_file is None: + original_file = ( + document.source_path if not use_overrides else document.original_file + ) messages = [] workflows = (