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:
parent
58b0947625
commit
c2de14dcab
3 changed files with 27 additions and 2 deletions
|
|
@ -130,6 +130,18 @@ impl Store {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Rebuild relation index from Vec. Call after mutations that modify relations.
|
||||
pub fn reindex_relations(&self) -> Result<()> {
|
||||
if let Some(db) = self.db.as_ref() {
|
||||
index::clear_relations(db)?;
|
||||
for rel in &self.relations {
|
||||
if rel.deleted { continue; }
|
||||
index::index_relation(db, &rel.source, &rel.target, rel.strength, rel.rel_type as u8)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn resolve_key(&self, target: &str) -> Result<String> {
|
||||
// Strip .md suffix if present — keys no longer use it
|
||||
let bare = strip_md_suffix(target);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue