diff --git a/src/structures.rs b/src/structures.rs index 235df77..c939cfd 100644 --- a/src/structures.rs +++ b/src/structures.rs @@ -3,7 +3,7 @@ use smallvec::SmallVec; use smartstring::alias::String as SmartString; -#[derive(Serialize, Clone)] +#[derive(Serialize, Clone, PartialEq)] #[serde(rename_all = "snake_case")] pub enum TaskStatus { InProgress, diff --git a/src/views.rs b/src/views.rs index ae411bc..1b3b8ab 100644 --- a/src/views.rs +++ b/src/views.rs @@ -8,7 +8,7 @@ use tower_http::trace::{TraceLayer, self}; use tracing::Level; -use crate::{config::CONFIG, structures::{Task, CreateTask}, services::{task_creator::create_task, utils::get_key}}; +use crate::{config::CONFIG, structures::{Task, CreateTask, TaskStatus}, services::{task_creator::create_task, utils::get_key}}; pub static TASK_RESULTS: Lazy> = Lazy::new(|| { @@ -25,7 +25,13 @@ async fn create_archive_task( let key = get_key(data.clone()); let result = match TASK_RESULTS.get(&key) { - Some(result) => result, + Some(result) => { + if result.status == TaskStatus::Failled { + create_task(data).await + } else { + result + } + }, None => create_task(data).await, };