fix: persist categorizations to capnp log
categorize() only updated the in-memory HashMap and state.json cache. When init appended new nodes to nodes.capnp (making it newer than state.json), the next load() would rebuild from capnp logs and lose all category assignments. Fix: append an updated node version to the capnp log when category changes, so it survives cache rebuilds. Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
23fac4e5fe
commit
6322b3fd61
1 changed files with 9 additions and 1 deletions
|
|
@ -711,8 +711,16 @@ impl Store {
|
||||||
pub fn categorize(&mut self, key: &str, cat_str: &str) -> Result<(), String> {
|
pub fn categorize(&mut self, key: &str, cat_str: &str) -> Result<(), String> {
|
||||||
let cat = Category::from_str(cat_str)
|
let cat = Category::from_str(cat_str)
|
||||||
.ok_or_else(|| format!("Unknown category '{}'. Use: core/tech/gen/obs/task", cat_str))?;
|
.ok_or_else(|| format!("Unknown category '{}'. Use: core/tech/gen/obs/task", cat_str))?;
|
||||||
if let Some(node) = self.nodes.get_mut(key) {
|
let updated = if let Some(node) = self.nodes.get_mut(key) {
|
||||||
node.category = cat;
|
node.category = cat;
|
||||||
|
node.version += 1;
|
||||||
|
Some(node.clone())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
if let Some(node) = updated {
|
||||||
|
// Persist to capnp log so category survives cache rebuilds
|
||||||
|
self.append_nodes(&[node])?;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(format!("No node '{}'", key))
|
Err(format!("No node '{}'", key))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue