| 368 | } |
| 369 | |
| 370 | pub async fn delete_task( |
| 371 | &self, |
| 372 | id: &str, |
| 373 | ) -> Result<(), Box<dyn std::error::Error + Send + Sync>> { |
| 374 | let conn = Arc::clone(&self.conn); |
| 375 | let id = id.to_string(); |
| 376 | tokio::task::spawn_blocking(move || { |
| 377 | let conn = conn.lock().map_err(|e| format!("Lock error: {e}"))?; |
| 378 | let rows_affected = |
| 379 | conn.execute("DELETE FROM tasks WHERE id = ?1", rusqlite::params![id])?; |
| 380 | if rows_affected == 0 { |
| 381 | return Err("Task not found".into()); |
| 382 | } |
| 383 | Ok(()) |
| 384 | }) |
| 385 | .await? |
| 386 | } |
| 387 | |
| 388 | /// Transition a task to Running status, setting `started_at` to now. |
| 389 | pub async fn mark_running( |