Resolve blocking commit deadlock and clippy warnings
This commit is contained in:
1 parent
afc7cbdad5
commit
cbd3d5801c
5 files changed
+55
-32
No files matched your search
+31
-14
@@ -56,26 +56,43 @@ impl MemoryState {
|
||||
self.graph.modify(update_fn);
|
||||
}
|
||||
|
||||
pub fn rebuild_index(&self) {
|
||||
pub async fn rebuild_index(&self) {
|
||||
if let Ok(new_idx) = MemoryIndex::new(&self.base_dir) {
|
||||
let graph = self.graph.read();
|
||||
for e in graph.entities.values() {
|
||||
let _ = new_idx.index_entity(e);
|
||||
let mut handles = Vec::new();
|
||||
|
||||
{
|
||||
let graph = self.graph.read();
|
||||
for e in graph.entities.values() {
|
||||
handles.push(new_idx.index_entity(e));
|
||||
}
|
||||
}
|
||||
|
||||
let tasks = self.tasks.read();
|
||||
for t in tasks {
|
||||
let _ = new_idx.index_task(&t);
|
||||
{
|
||||
let tasks = self.tasks.read();
|
||||
for t in tasks {
|
||||
handles.push(new_idx.index_task(&t));
|
||||
}
|
||||
}
|
||||
let snippets = self.snippets.read();
|
||||
for s in snippets {
|
||||
let _ = new_idx.index_snippet(&s);
|
||||
|
||||
{
|
||||
let snippets = self.snippets.read();
|
||||
for s in snippets {
|
||||
handles.push(new_idx.index_snippet(&s));
|
||||
}
|
||||
}
|
||||
let adrs = self.adrs.read();
|
||||
for a in adrs {
|
||||
let _ = new_idx.index_adr(&a);
|
||||
|
||||
{
|
||||
let adrs = self.adrs.read();
|
||||
for a in adrs {
|
||||
handles.push(new_idx.index_adr(&a));
|
||||
}
|
||||
}
|
||||
let _ = new_idx.commit();
|
||||
|
||||
for handle in handles {
|
||||
let _ = handle.await;
|
||||
}
|
||||
|
||||
let _ = new_idx.commit().await;
|
||||
if let Ok(mut w) = self.search_index.write() {
|
||||
*w = new_idx;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user