store: add reindex_relations for after Vec mutations

- Add index::clear_relations() to drop and recreate RELS table
- Add Store::reindex_relations() to rebuild index from Vec
- Call reindex_relations() at end of dedup command

This ensures index stays in sync with Vec after complex mutations
like UUID redirection in dedup. Vec mutations remain for now but
index is correctly updated afterward.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2026-04-13 21:24:49 -04:00
parent 58b0947625
commit c2de14dcab
3 changed files with 27 additions and 2 deletions

View file

@ -61,7 +61,7 @@ pub async fn cmd_fsck() -> Result<()> {
store::fsck()?;
let arc = memory::access_local()?;
let mut store = arc.lock().await;
let store = arc.lock().await;
// Check node-key consistency
let mut issues = 0;
@ -287,8 +287,9 @@ pub async fn cmd_dedup(apply: bool) -> Result<()> {
merged += doomed_uuids.len();
}
// Remove tombstoned relations from cache
// Remove tombstoned relations from cache and rebuild index
store.relations.retain(|r| !r.deleted);
store.reindex_relations()?;
store.save()?;
println!("Merged {} duplicates, redirected {} edges, deduped {} duplicate edges",