From d49431cfc7bf52d972b2fdc831c21cdb6ddc093d Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 23 Aug 2022 19:22:14 +0200 Subject: [PATCH] events: reset task info when not saving on success Signed-off-by: Jens Langhammer --- authentik/events/monitored_tasks.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/authentik/events/monitored_tasks.py b/authentik/events/monitored_tasks.py index 2c9dcc85e..ea537b42d 100644 --- a/authentik/events/monitored_tasks.py +++ b/authentik/events/monitored_tasks.py @@ -139,9 +139,7 @@ class MonitoredTask(Task): return if not self._result.uid: self._result.uid = self._uid - if self._result.status == TaskResultStatus.SUCCESSFUL and not self.save_on_success: - return - TaskInfo( + info = TaskInfo( task_name=self.__name__, task_description=self.__doc__, start_timestamp=self.start, @@ -152,7 +150,11 @@ class MonitoredTask(Task): task_call_func=self.__name__, task_call_args=args, task_call_kwargs=kwargs, - ).save(self.result_timeout_hours) + ) + if self._result.status == TaskResultStatus.SUCCESSFUL and not self.save_on_success: + info.delete() + return + info.save(self.result_timeout_hours) # pylint: disable=too-many-arguments def on_failure(self, exc, task_id, args, kwargs, einfo):