(job_id: web::Path<String>, job_store: web::Data<JobStore>)
| 370 | } |
| 371 | |
| 372 | async fn stop_job(job_id: web::Path<String>, job_store: web::Data<JobStore>) -> impl Responder { |
| 373 | let mut store = job_store.lock().await; |
| 374 | let response = match store.get_mut(job_id.as_str()) { |
| 375 | Some(status) => { |
| 376 | if status.video_url.is_none() && status.error.is_none() { |
| 377 | status.error = Some("Job stopped by user".to_string()); |
| 378 | |
| 379 | log_message( |
| 380 | log::Level::Info, |
| 381 | &format!("Job {} stopped by user", job_id), |
| 382 | Some(job_id.as_str()), |
| 383 | ); |
| 384 | serde_json::json!({ |
| 385 | "message": "Job stopped successfully and temporary files cleaned up", |
| 386 | "status": "stopped" |
| 387 | }) |
| 388 | } else { |
| 389 | log_message( |
| 390 | log::Level::Info, |
| 391 | &format!("Cannot stop job {}: already completed or errored", job_id), |
| 392 | Some(job_id.as_str()), |
| 393 | ); |
| 394 | serde_json::json!({ |
| 395 | "error": "Cannot stop job: already completed or errored", |
| 396 | "status": "unchanged" |
| 397 | }) |
| 398 | } |
| 399 | } |
| 400 | None => { |
| 401 | log_message( |
| 402 | log::Level::Info, |
| 403 | &format!("Job not found: {}", job_id), |
| 404 | Some(job_id.as_str()), |
| 405 | ); |
| 406 | serde_json::json!({ |
| 407 | "error": "Job not found", |
| 408 | "status": "not_found" |
| 409 | }) |
| 410 | } |
| 411 | }; |
| 412 | |
| 413 | HttpResponse::Ok().json(response) |
| 414 | } |
| 415 | |
| 416 | async fn get_job_status( |
| 417 | job_id: web::Path<String>, |
nothing calls this directly
no test coverage detected