| 547 | } |
| 548 | |
| 549 | async fn load_workflow_checkpoint( |
| 550 | &self, |
| 551 | workflow_id: &str, |
| 552 | ) -> Result<Option<WorkflowCheckpoint>> { |
| 553 | let path = self.workflow_checkpoint_path(workflow_id); |
| 554 | if !path.exists() { |
| 555 | return Ok(None); |
| 556 | } |
| 557 | let json = fs::read_to_string(&path).await.with_context(|| { |
| 558 | format!("Failed to read workflow checkpoint from {}", path.display()) |
| 559 | })?; |
| 560 | let checkpoint: WorkflowCheckpoint = serde_json::from_str(&json).with_context(|| { |
| 561 | format!( |
| 562 | "Failed to parse workflow checkpoint from {}", |
| 563 | path.display() |
| 564 | ) |
| 565 | })?; |
| 566 | // Refuse a future, incompatible schema version (see ensure_loadable). |
| 567 | checkpoint.ensure_loadable()?; |
| 568 | Ok(Some(checkpoint)) |
| 569 | } |
| 570 | |
| 571 | async fn delete_workflow_checkpoint(&self, workflow_id: &str) -> Result<()> { |
| 572 | let path = self.workflow_checkpoint_path(workflow_id); |