mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-25 19:45:05 +08: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();
|
||||||
let server = Server::new_shared();
|
|
||||||
server._index("EMPTY_INDEX").to_shared()
|
INDEX
|
||||||
});
|
.get_or_init(|| async {
|
||||||
let index = Lazy::get(&INDEX);
|
let server = Server::new_shared();
|
||||||
// That means the lazy has never been initialized, we need to create the index and index the documents
|
let index = server._index("EMPTY_INDEX").to_shared();
|
||||||
if index.is_none() {
|
let (response, _code) = index._create(None).await;
|
||||||
let (response, _code) = INDEX._create(None).await;
|
index.wait_task(response.uid()).await.succeeded();
|
||||||
INDEX.wait_task(response.uid()).await.succeeded();
|
index
|
||||||
}
|
})
|
||||||
&INDEX
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub static DOCUMENTS: Lazy<Value> = Lazy::new(|| {
|
pub static DOCUMENTS: Lazy<Value> = Lazy::new(|| {
|
||||||
|
Loading…
Reference in New Issue
Block a user