Stores and executes a task inline, for use by `run` and `shell` commands. Unlike server-scheduled tasks (which are added to the queue as `Queued` and later picked up by the scheduler), `run` and `shell` execute tasks directly. This method persists the task as `Running` before execution so it appears in `tsk list` and can be used as a parent for task chaining. The `Running` status prevents the ser
(
&self,
task: &Task,
)
| 80 | /// parent for task chaining. The `Running` status prevents the server scheduler from |
| 81 | /// picking it up. |
| 82 | pub async fn store_and_run( |
| 83 | &self, |
| 84 | task: &Task, |
| 85 | ) -> Result<TaskExecutionResult, TaskExecutionError> { |
| 86 | let mut stored_task = task.clone(); |
| 87 | stored_task.status = TaskStatus::Running; |
| 88 | stored_task.started_at = Some(chrono::Utc::now()); |
| 89 | if let Err(e) = self.task_storage.add_task(stored_task).await { |
| 90 | emit_or_print( |
| 91 | &self.event_sender, |
| 92 | ServerEvent::WarningMessage(format!("Error storing task: {e}")), |
| 93 | ); |
| 94 | } |
| 95 | self.run_with_lifecycle(task).await |
| 96 | } |
| 97 | |
| 98 | /// Execute a task from the queue with status updates. |
| 99 | /// |