From 91e80d01bcc44e4f6d346e461708a763879057cc Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Thu, 15 Apr 2021 11:25:58 -0400 Subject: [PATCH] Added delete_files argument to the workflow_processor reset method. Added code to delete the files when delete_files is True. --- crc/services/workflow_processor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crc/services/workflow_processor.py b/crc/services/workflow_processor.py index 9016b807..f0a6fa72 100644 --- a/crc/services/workflow_processor.py +++ b/crc/services/workflow_processor.py @@ -174,7 +174,7 @@ class WorkflowProcessor(object): self.is_latest_spec = False @staticmethod - def reset(workflow_model, clear_data=False): + def reset(workflow_model, clear_data=False, delete_files=False): print('WorkflowProcessor: reset: ') # Try to execute a cancel notify @@ -194,6 +194,10 @@ class WorkflowProcessor(object): for task_event in task_events: task_event.form_data = {} session.add(task_event) + if delete_files: + files = FileModel.query.filter(FileModel.workflow_id == workflow_model.id).all() + for file in files: + FileService.delete_file(file.id) session.commit() return WorkflowProcessor(workflow_model)