aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/ops.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/ops.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/ops.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/ops.py b/packages/meshbay-node/src/meshbay_node/ops.py
index 11694c3..10f6a8f 100644
--- a/packages/meshbay-node/src/meshbay_node/ops.py
+++ b/packages/meshbay-node/src/meshbay_node/ops.py
@@ -682,9 +682,30 @@ async def add_root(state: dict, group_id: str, path: str, *,
writable=added.writable, removable=added.removable,
direct=added.direct))
+ # The *live* set, not only the config — the same thing `remove_root` and
+ # `update_root` do, and the one this was missing.
+ #
+ # `_retarget_indexer` (the MNP path) re-points the indexer at
+ # `groups_ctx[gid]["roots"]`, so leaving that object untouched retargeted
+ # it at exactly what it already had: node.toml gained the directory, the
+ # index went on reporting the old set, and the next `index_sync` overwrote
+ # whatever the ack had just told the client. The root was there, invisible,
+ # until a restart — and adding it again was refused as a duplicate of
+ # itself, which is the only reason anyone found out.
+ #
+ # Safe to append rather than rebuild: `RootSet.build(specs)` above already
+ # validated the whole set, this root included, for name collisions and
+ # nesting.
+ live_roots: RootSet | None = state.get("groups_ctx", {}).get(
+ group_id, {}).get("roots")
+ if live_roots is not None and not any(
+ r.folded == added.folded for r in live_roots.roots):
+ live_roots.roots.append(added)
+
log.info("Root added: %s → group %s", added.name, group_id[:8])
return {"status": "added", "name": added.name, "path": str(added.path),
- "group_id": group_id, "roots": built.describe()}
+ "group_id": group_id,
+ "roots": (live_roots or built).describe()}
async def remove_root(state: dict, group_id: str, root_name: str) -> dict: