mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 06:44:27 +01:00
Return an internal error when index pattern should be valid
This commit is contained in:
parent
47748395dc
commit
4b1cd10653
@ -5,6 +5,7 @@ use std::convert::{TryFrom, TryInto};
|
|||||||
use std::fs::create_dir_all;
|
use std::fs::create_dir_all;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use hmac::{Hmac, Mac};
|
use hmac::{Hmac, Mac};
|
||||||
@ -18,7 +19,7 @@ use time::OffsetDateTime;
|
|||||||
use uuid::fmt::Hyphenated;
|
use uuid::fmt::Hyphenated;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use super::error::Result;
|
use super::error::{AuthControllerError, Result};
|
||||||
use super::{Action, Key};
|
use super::{Action, Key};
|
||||||
|
|
||||||
const AUTH_STORE_SIZE: usize = 1_073_741_824; //1GiB
|
const AUTH_STORE_SIZE: usize = 1_073_741_824; //1GiB
|
||||||
@ -225,9 +226,9 @@ impl HeedAuthStore {
|
|||||||
for result in self.action_keyid_index_expiration.prefix_iter(&rtxn, &tuple)? {
|
for result in self.action_keyid_index_expiration.prefix_iter(&rtxn, &tuple)? {
|
||||||
let ((_, _, index_uid_pattern), expiration) = result?;
|
let ((_, _, index_uid_pattern), expiration) = result?;
|
||||||
if let Some((pattern, index)) = index_uid_pattern.zip(index) {
|
if let Some((pattern, index)) = index_uid_pattern.zip(index) {
|
||||||
let index_uid_pattern = str::from_utf8(pattern)?.to_string();
|
let index_uid_pattern = str::from_utf8(pattern)?;
|
||||||
// TODO I shouldn't unwrap here but rather return an internal error
|
let pattern = IndexUidPattern::from_str(index_uid_pattern)
|
||||||
let pattern = IndexUidPattern::try_from(index_uid_pattern).unwrap();
|
.map_err(|e| AuthControllerError::Internal(Box::new(e)))?;
|
||||||
if pattern.matches_str(index) {
|
if pattern.matches_str(index) {
|
||||||
return Ok(Some(expiration));
|
return Ok(Some(expiration));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user