diff --git a/meilisearch-lib/src/index_controller/mod.rs b/meilisearch-lib/src/index_controller/mod.rs index ecca9ac63..81dd5b7c7 100644 --- a/meilisearch-lib/src/index_controller/mod.rs +++ b/meilisearch-lib/src/index_controller/mod.rs @@ -3,6 +3,7 @@ use std::collections::BTreeMap; use std::fmt; use std::io::Cursor; use std::path::{Path, PathBuf}; +use std::str::FromStr; use std::sync::Arc; use std::time::Duration; @@ -23,6 +24,7 @@ use crate::dump::{self, load_dump, DumpHandler}; use crate::index::{ Checked, Document, IndexMeta, IndexStats, SearchQuery, SearchResult, Settings, Unchecked, }; +use crate::index_resolver::error::IndexResolverError; use crate::options::{IndexerOpts, SchedulerConfig}; use crate::snapshot::{load_snapshot, SnapshotService}; use crate::tasks::error::TaskError; @@ -356,7 +358,7 @@ where } pub async fn register_update(&self, uid: String, update: Update) -> Result { - let index_uid = IndexUid::new(uid)?; + let index_uid = IndexUid::from_str(&uid).map_err(IndexResolverError::from)?; let content = match update { Update::DeleteDocuments(ids) => TaskContent::DocumentDeletion { index_uid, diff --git a/meilisearch-lib/src/index_resolver/mod.rs b/meilisearch-lib/src/index_resolver/mod.rs index a7991e8ef..894eea9c5 100644 --- a/meilisearch-lib/src/index_resolver/mod.rs +++ b/meilisearch-lib/src/index_resolver/mod.rs @@ -48,18 +48,6 @@ pub fn create_index_resolver( } impl IndexUid { - pub fn new(uid: String) -> Result { - if !uid - .chars() - .all(|x| x.is_ascii_alphanumeric() || x == '-' || x == '_') - || !(1..=400).contains(&uid.len()) - { - Err(IndexResolverError::BadlyFormatted(uid)) - } else { - Ok(Self(uid)) - } - } - pub fn new_unchecked(s: impl AsRef) -> Self { Self(s.as_ref().to_string()) }