aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/daemon.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-20 22:21:24 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-20 22:21:24 +0200
commitae52b69b14a6997d01aad66f49fbea7b5ca2dfe6 (patch)
tree26f850a88565846a139868a4b85c715734751a41 /packages/meshbay-node/src/meshbay_node/daemon.py
parentc8af746c846b5dbc792f7e4f0d806647d513cc5c (diff)
parent2e9490ca27047ae03e495d397abbe1aec1b2273a (diff)
downloadmeshbay-ae52b69b14a6997d01aad66f49fbea7b5ca2dfe6.tar.gz
Merge feat/unified-group-management: wizard, public groups, activity sidebar
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/daemon.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/daemon.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/daemon.py b/packages/meshbay-node/src/meshbay_node/daemon.py
index 7e3ebc1..385a1da 100644
--- a/packages/meshbay-node/src/meshbay_node/daemon.py
+++ b/packages/meshbay-node/src/meshbay_node/daemon.py
@@ -125,6 +125,7 @@ class NodeDaemon:
self._indexers: list[DirectoryIndexer] = []
self._tasks: list[asyncio.Task] = []
self._hub: HubClient | None = None
+ self._reload_lock = asyncio.Lock()
async def run(self) -> None:
log.info("MeshBay Node starting up")
@@ -225,14 +226,13 @@ class NodeDaemon:
", ".join(str(r.path) for r in roots))
gek = None
- if group_cfg.visibility == "private":
- gek = await self._load_gek(
- group_cfg.id, session.user_id, sk_x_raw, pk_x_raw)
- if gek:
- log.info("GEK loaded for group %s", group_cfg.id[:8])
- else:
- log.info("No GEK yet for group %s — will accept first setup",
- group_cfg.name)
+ gek = await self._load_gek(
+ group_cfg.id, session.user_id, sk_x_raw, pk_x_raw)
+ if gek:
+ log.info("GEK loaded for group %s", group_cfg.id[:8])
+ else:
+ log.info("No GEK yet for group %s — will accept first setup",
+ group_cfg.name)
indexer = DirectoryIndexer(
roots=roots,
@@ -399,7 +399,7 @@ class NodeDaemon:
on_incoming=on_incoming,
on_revocation=on_revocation,
on_webrtc_offer=on_webrtc_offer,
- group_ids=list(groups_ctx.keys()),
+ group_ids=lambda: list((self._state.get("groups_ctx") or {}).keys()),
))
self._tasks.append(ws_task)
log.info("Hub WS task started")
@@ -470,7 +470,15 @@ class NodeDaemon:
Handles root changes on existing groups, hot-loads new groups, and
tears down removed groups. Existing connections are untouched: a member
watching a film keeps watching it.
+
+ Serialised by _reload_lock: fire-and-forget reloads from config-mutating
+ endpoints can overlap with the wizard's explicit /api/reload call,
+ and two concurrent hot-loads of the same group corrupt the runtime state.
"""
+ async with self._reload_lock:
+ await self._reload_config_inner()
+
+ async def _reload_config_inner(self) -> None:
log.info("Reloading config from %s", self._config_path)
try:
fresh = load_config(self._config_path)
@@ -537,7 +545,7 @@ class NodeDaemon:
roots.refresh_availability()
gek = None
- if group_cfg.visibility == "private" and sk_x_raw and pk_x_raw:
+ if sk_x_raw and pk_x_raw:
gek = await self._load_gek(
group_cfg.id, node_user_id, sk_x_raw, pk_x_raw)
if gek:
@@ -616,6 +624,10 @@ class NodeDaemon:
log.info("Reload complete — %d re-rooted, %d added, %d removed",
changed, len(added_names), len(removed_names))
+ if (added_names or removed_names) and self._hub:
+ gids = list((self._state.get("groups_ctx") or {}).keys())
+ await self._hub.update_ws_groups(gids)
+
async def _login_with_retry(self, hub: HubClient):
"""Login to hub, retrying if the node key hasn't been linked yet."""
import httpx as _httpx