mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-01 17:15:46 +01:00
fix a sync issue on empty indexes
This commit is contained in:
parent
ded3cd0dd6
commit
7a5a38f870
@ -149,17 +149,17 @@ pub async fn shared_does_not_exists_index() -> &'static Index<'static, Shared> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn shared_empty_index() -> &'static Index<'static, Shared> {
|
pub async fn shared_empty_index() -> &'static Index<'static, Shared> {
|
||||||
static INDEX: Lazy<Index<'static, Shared>> = Lazy::new(|| {
|
static INDEX: OnceCell<Index<'static, Shared>> = OnceCell::const_new();
|
||||||
|
|
||||||
|
INDEX
|
||||||
|
.get_or_init(|| async {
|
||||||
let server = Server::new_shared();
|
let server = Server::new_shared();
|
||||||
server._index("EMPTY_INDEX").to_shared()
|
let index = server._index("EMPTY_INDEX").to_shared();
|
||||||
});
|
let (response, _code) = index._create(None).await;
|
||||||
let index = Lazy::get(&INDEX);
|
index.wait_task(response.uid()).await.succeeded();
|
||||||
// That means the lazy has never been initialized, we need to create the index and index the documents
|
index
|
||||||
if index.is_none() {
|
})
|
||||||
let (response, _code) = INDEX._create(None).await;
|
.await
|
||||||
INDEX.wait_task(response.uid()).await.succeeded();
|
|
||||||
}
|
|
||||||
&INDEX
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub static DOCUMENTS: Lazy<Value> = Lazy::new(|| {
|
pub static DOCUMENTS: Lazy<Value> = Lazy::new(|| {
|
||||||
|
Loading…
Reference in New Issue
Block a user