mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 00:55:00 +08:00
Index UID generation makes sure to not generate the same number
This commit is contained in:
parent
b3b73e2276
commit
0f86ccc035
@ -146,10 +146,15 @@ pub async fn create_index(mut ctx: Context<Data>) -> SResult<Response> {
|
|||||||
.await
|
.await
|
||||||
.map_err(ResponseError::bad_request)?;
|
.map_err(ResponseError::bad_request)?;
|
||||||
|
|
||||||
let generated_uid = generate_uid();
|
|
||||||
|
|
||||||
let db = &ctx.state().db;
|
let db = &ctx.state().db;
|
||||||
|
|
||||||
|
let generated_uid = loop {
|
||||||
|
let uid = generate_uid();
|
||||||
|
if db.open_index(&uid).is_none() {
|
||||||
|
break uid;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let created_index = match db.create_index(&generated_uid) {
|
let created_index = match db.create_index(&generated_uid) {
|
||||||
Ok(index) => index,
|
Ok(index) => index,
|
||||||
Err(e) => return Err(ResponseError::create_index(e)),
|
Err(e) => return Err(ResponseError::create_index(e)),
|
||||||
|
Loading…
Reference in New Issue
Block a user