mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
fix workflow process
This commit is contained in:
@@ -17,9 +17,11 @@ class WorkflowChain(ChainBase):
|
|||||||
self.workflowoper = WorkflowOper()
|
self.workflowoper = WorkflowOper()
|
||||||
self.workflowmanager = WorkFlowManager()
|
self.workflowmanager = WorkFlowManager()
|
||||||
|
|
||||||
def process(self, workflow_id: int) -> bool:
|
def process(self, workflow_id: int, from_begin: bool = True) -> bool:
|
||||||
"""
|
"""
|
||||||
处理工作流
|
处理工作流
|
||||||
|
:param workflow_id: 工作流ID
|
||||||
|
:param from_begin: 是否从头开始,默认为True
|
||||||
"""
|
"""
|
||||||
workflow = self.workflowoper.get(workflow_id)
|
workflow = self.workflowoper.get(workflow_id)
|
||||||
if not workflow:
|
if not workflow:
|
||||||
@@ -30,9 +32,14 @@ class WorkflowChain(ChainBase):
|
|||||||
return False
|
return False
|
||||||
logger.info(f"开始处理 {workflow.name},共 {len(workflow.actions)} 个动作 ...")
|
logger.info(f"开始处理 {workflow.name},共 {len(workflow.actions)} 个动作 ...")
|
||||||
# 启用上下文
|
# 启用上下文
|
||||||
context = ActionContext()
|
if not from_begin and workflow.current_action:
|
||||||
|
context = ActionContext(**workflow.context)
|
||||||
|
else:
|
||||||
|
context = ActionContext()
|
||||||
self.workflowoper.start(workflow_id)
|
self.workflowoper.start(workflow_id)
|
||||||
for act in workflow.actions:
|
for act in workflow.actions:
|
||||||
|
if not from_begin and act['id'] != workflow.current_action:
|
||||||
|
continue
|
||||||
action = Action(**act)
|
action = Action(**act)
|
||||||
state, context = self.workflowmanager.excute(action, context)
|
state, context = self.workflowmanager.excute(action, context)
|
||||||
self.workflowoper.step(workflow_id, action=action.name, context=context.dict())
|
self.workflowoper.step(workflow_id, action=action.name, context=context.dict())
|
||||||
|
|||||||
Reference in New Issue
Block a user