mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
correct error on settings delete unexisting index
This commit is contained in:
parent
30dd790884
commit
66b64c1f80
@ -23,9 +23,10 @@ impl Data {
|
|||||||
pub async fn update_settings(
|
pub async fn update_settings(
|
||||||
&self,
|
&self,
|
||||||
index: String,
|
index: String,
|
||||||
settings: Settings
|
settings: Settings,
|
||||||
|
create: bool,
|
||||||
) -> anyhow::Result<UpdateStatus> {
|
) -> anyhow::Result<UpdateStatus> {
|
||||||
let update = self.index_controller.update_settings(index, settings).await?;
|
let update = self.index_controller.update_settings(index, settings, create).await?;
|
||||||
Ok(update.into())
|
Ok(update.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,8 +129,12 @@ impl IndexController {
|
|||||||
Ok(status)
|
Ok(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_settings(&self, index_uid: String, settings: Settings) -> anyhow::Result<UpdateStatus> {
|
pub async fn update_settings(&self, index_uid: String, settings: Settings, create: bool) -> anyhow::Result<UpdateStatus> {
|
||||||
let uuid = self.uuid_resolver.get_or_create(index_uid).await?;
|
let uuid = if create {
|
||||||
|
self.uuid_resolver.get_or_create(index_uid).await?
|
||||||
|
} else {
|
||||||
|
self.uuid_resolver.resolve(index_uid).await?
|
||||||
|
};
|
||||||
let meta = UpdateMeta::Settings(settings);
|
let meta = UpdateMeta::Settings(settings);
|
||||||
// Nothing so send, drop the sender right away, as not to block the update actor.
|
// Nothing so send, drop the sender right away, as not to block the update actor.
|
||||||
let (_, receiver) = mpsc::channel(1);
|
let (_, receiver) = mpsc::channel(1);
|
||||||
|
@ -26,7 +26,7 @@ macro_rules! make_setting_route {
|
|||||||
$attr: Some(None),
|
$attr: Some(None),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
match data.update_settings(index_uid.into_inner(), settings).await {
|
match data.update_settings(index_uid.into_inner(), settings, false).await {
|
||||||
Ok(update_status) => {
|
Ok(update_status) => {
|
||||||
let json = serde_json::to_string(&update_status).unwrap();
|
let json = serde_json::to_string(&update_status).unwrap();
|
||||||
Ok(HttpResponse::Ok().body(json))
|
Ok(HttpResponse::Ok().body(json))
|
||||||
@ -48,7 +48,7 @@ macro_rules! make_setting_route {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
match data.update_settings(index_uid.into_inner(), settings).await {
|
match data.update_settings(index_uid.into_inner(), settings, true).await {
|
||||||
Ok(update_status) => {
|
Ok(update_status) => {
|
||||||
let json = serde_json::to_string(&update_status).unwrap();
|
let json = serde_json::to_string(&update_status).unwrap();
|
||||||
Ok(HttpResponse::Ok().body(json))
|
Ok(HttpResponse::Ok().body(json))
|
||||||
@ -137,7 +137,7 @@ async fn update_all(
|
|||||||
index_uid: web::Path<String>,
|
index_uid: web::Path<String>,
|
||||||
body: web::Json<Settings>,
|
body: web::Json<Settings>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
match data.update_settings(index_uid.into_inner(), body.into_inner()).await {
|
match data.update_settings(index_uid.into_inner(), body.into_inner(), true).await {
|
||||||
Ok(update_result) => {
|
Ok(update_result) => {
|
||||||
let json = serde_json::to_string(&update_result).unwrap();
|
let json = serde_json::to_string(&update_result).unwrap();
|
||||||
Ok(HttpResponse::Ok().body(json))
|
Ok(HttpResponse::Ok().body(json))
|
||||||
@ -170,7 +170,7 @@ async fn delete_all(
|
|||||||
index_uid: web::Path<String>,
|
index_uid: web::Path<String>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
let settings = Settings::cleared();
|
let settings = Settings::cleared();
|
||||||
match data.update_settings(index_uid.into_inner(), settings).await {
|
match data.update_settings(index_uid.into_inner(), settings, false).await {
|
||||||
Ok(update_result) => {
|
Ok(update_result) => {
|
||||||
let json = serde_json::to_string(&update_result).unwrap();
|
let json = serde_json::to_string(&update_result).unwrap();
|
||||||
Ok(HttpResponse::Ok().body(json))
|
Ok(HttpResponse::Ok().body(json))
|
||||||
|
Loading…
Reference in New Issue
Block a user