mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-23 13:10:06 +01:00
forbid deserialization of Setting<Checked>
This commit is contained in:
parent
3a7c1f2469
commit
d0552e765e
@ -82,7 +82,7 @@ impl UpdateHandler {
|
|||||||
),
|
),
|
||||||
ClearDocuments => index.clear_documents(update_builder),
|
ClearDocuments => index.clear_documents(update_builder),
|
||||||
DeleteDocuments => index.delete_documents(content, update_builder),
|
DeleteDocuments => index.delete_documents(content, update_builder),
|
||||||
Settings(settings) => index.update_settings(settings, update_builder),
|
Settings(settings) => index.update_settings(&settings.clone().check(), update_builder),
|
||||||
};
|
};
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
|
@ -20,14 +20,15 @@ where
|
|||||||
s.serialize_some(&field.as_ref().map(|o| o.as_ref().unwrap_or(&wildcard)))
|
s.serialize_some(&field.as_ref().map(|o| o.as_ref().unwrap_or(&wildcard)))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, Debug)]
|
#[derive(Clone, Default, Debug, Serialize)]
|
||||||
pub struct Checked;
|
pub struct Checked;
|
||||||
#[derive(Clone, Default, Debug)]
|
#[derive(Clone, Default, Debug, Serialize, Deserialize)]
|
||||||
pub struct Unchecked;
|
pub struct Unchecked;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[serde(bound(serialize = "T: Serialize", deserialize = "T: Deserialize<'static>"))]
|
||||||
pub struct Settings<T> {
|
pub struct Settings<T> {
|
||||||
#[serde(
|
#[serde(
|
||||||
default,
|
default,
|
||||||
|
@ -223,7 +223,7 @@ impl IndexController {
|
|||||||
create: bool,
|
create: bool,
|
||||||
) -> anyhow::Result<UpdateStatus> {
|
) -> anyhow::Result<UpdateStatus> {
|
||||||
let perform_udpate = |uuid| async move {
|
let perform_udpate = |uuid| async move {
|
||||||
let meta = UpdateMeta::Settings(settings);
|
let meta = UpdateMeta::Settings(settings.into_unchecked());
|
||||||
// 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);
|
||||||
self.update_handle.update(meta, receiver, uuid).await
|
self.update_handle.update(meta, receiver, uuid).await
|
||||||
|
@ -3,7 +3,7 @@ use milli::update::{DocumentAdditionResult, IndexDocumentsMethod, UpdateFormat};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::index::{Checked, Settings};
|
use crate::index::{Unchecked, Settings};
|
||||||
|
|
||||||
pub type UpdateError = String;
|
pub type UpdateError = String;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ pub enum UpdateMeta {
|
|||||||
},
|
},
|
||||||
ClearDocuments,
|
ClearDocuments,
|
||||||
DeleteDocuments,
|
DeleteDocuments,
|
||||||
Settings(Settings<Checked>),
|
Settings(Settings<Unchecked>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user