From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 16 Jan 2025 06:13:40 +0000 (-0800) Subject: Refactor: consolidate original_file logic in wf handler X-Git-Tag: v2.14.4~1^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f68ee628d9e2d6fbc8a9b8c975da8eadeaeec794;p=thirdparty%2Fpaperless-ngx.git Refactor: consolidate original_file logic in wf handler --- 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 = (