From c641888a2301cd3a29170a75446933de6e6e58fa Mon Sep 17 00:00:00 2001 From: Kerollmops Date: Wed, 26 Oct 2022 11:11:53 +0200 Subject: [PATCH] Patch the delete and cancel tasks routes --- meilisearch-http/src/routes/mod.rs | 2 +- meilisearch-http/src/routes/tasks.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/meilisearch-http/src/routes/mod.rs b/meilisearch-http/src/routes/mod.rs index fb6462f84..4463aee5e 100644 --- a/meilisearch-http/src/routes/mod.rs +++ b/meilisearch-http/src/routes/mod.rs @@ -31,7 +31,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) { .service(web::resource("/stats").route(web::get().to(get_stats))) .service(web::resource("/version").route(web::get().to(get_version))) .service(web::scope("/indexes").configure(indexes::configure)) - .service(web::scope("swap-indexes").configure(swap_indexes::configure)); + .service(web::scope("/swap-indexes").configure(swap_indexes::configure)); } /// Extracts the raw values from the `StarOr` types and diff --git a/meilisearch-http/src/routes/tasks.rs b/meilisearch-http/src/routes/tasks.rs index f2d759276..e10779012 100644 --- a/meilisearch-http/src/routes/tasks.rs +++ b/meilisearch-http/src/routes/tasks.rs @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize}; use serde_cs::vec::CS; use serde_json::json; use time::{Duration, OffsetDateTime}; -use tokio::task::block_in_place; +use tokio::task; use super::fold_star_or; use crate::analytics::Analytics; @@ -26,8 +26,8 @@ pub fn configure(cfg: &mut web::ServiceConfig) { .route(web::get().to(SeqHandler(get_tasks))) .route(web::delete().to(SeqHandler(delete_tasks))), ) - .service(web::resource("/{task_id}").route(web::get().to(SeqHandler(get_task)))) - .service(web::resource("/cancel").route(web::post().to(SeqHandler(cancel_tasks)))); + .service(web::resource("/cancel").route(web::post().to(SeqHandler(cancel_tasks)))) + .service(web::resource("/{task_id}").route(web::get().to(SeqHandler(get_task)))); } #[derive(Debug, Clone, PartialEq, Serialize)] @@ -294,7 +294,7 @@ async fn cancel_tasks( let task_cancelation = KindWithContent::TaskCancelation { query: req.query_string().to_string(), tasks }; - let task = block_in_place(|| index_scheduler.register(task_cancelation))?; + let task = task::spawn_blocking(move || index_scheduler.register(task_cancelation)).await??; let task_view = TaskView::from_task(&task); Ok(HttpResponse::Ok().json(task_view)) @@ -351,7 +351,7 @@ async fn delete_tasks( let task_deletion = KindWithContent::TaskDeletion { query: req.query_string().to_string(), tasks }; - let task = block_in_place(|| index_scheduler.register(task_deletion))?; + let task = task::spawn_blocking(move || index_scheduler.register(task_deletion)).await??; let task_view = TaskView::from_task(&task); Ok(HttpResponse::Ok().json(task_view))