summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/ops.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-24 22:24:52 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-24 22:24:52 +0200
commit665fb2004e55b72ea483aa50fea81f6a6fd9c322 (patch)
treecc412f776cf993fc5c242750787c9e5c81aa3241 /packages/meshbay-node/src/meshbay_node/ops.py
parent626365668508790dee70ab192a7d6c6f14725bf4 (diff)
downloadmeshbay-665fb2004e55b72ea483aa50fea81f6a6fd9c322.tar.gz
feat(node): add audio_root, gate Music enrichment on it like video_root
musicbay.md's original call — Music needs no root, tag reads are cheap so just cover the whole shared tree — didn't hold up against a real messy library: everything under every shared folder got mixed together with no way to scope Music down to an actual music collection. This adds an audio_root setting, symmetric to video_root in every respect: signed operator op (audio_root/audio_root_ack, MNP bumped to 0.10), validated against a real directory in the group's own roots before a signature is even asked for, gates tag/cover enrichment exactly like video_root gates ffprobe/TMDB (nothing runs until it's set, only files under it once it is), and a set/change fires a one-off sweep of whatever the folder already contains. The old trigger — sweep everything the instant "music" joins enabled_apps — is gone along with the root-less design it belonged to; setting audio_root is now the trigger, mirroring set_video_root's enrich_video_root_fn exactly. Test coverage mirrors the video_root suite: policy (refuse before a signature round trip, accept/store correctly) and the enrichment gate itself (nothing without a root, only files under it, sweep on set).
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/ops.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/ops.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/ops.py b/packages/meshbay-node/src/meshbay_node/ops.py
index d439ec3..1da6928 100644
--- a/packages/meshbay-node/src/meshbay_node/ops.py
+++ b/packages/meshbay-node/src/meshbay_node/ops.py
@@ -728,14 +728,6 @@ async def set_enabled_apps(state: dict, group_id: str, apps: list[str]) -> dict:
set_by=state.get("node_user_id", ""))
ctx["enabled_apps"] = apps
log.info("Enabled apps for group %s: %s", group_id[:8], ",".join(sorted(apps)))
- if "music" in apps:
- # Music has no root of its own to key a sweep off (unlike
- # set_video_root's enrich_video_root_fn) — turning the app on at all
- # is the trigger, mirroring that same "sweep what's already there"
- # need (docs/musicbay.md §2.1, daemon._enrich_music_now).
- enrich_fn = state.get("enrich_music_now_fn")
- if enrich_fn:
- asyncio.ensure_future(enrich_fn(group_id))
return {"apps": apps, "group_id": group_id}
@@ -850,6 +842,27 @@ async def set_video_root(state: dict, group_id: str, path: str) -> dict:
return {"path": path, "group_id": group_id}
+async def set_audio_root(state: dict, group_id: str, path: str) -> dict:
+ """
+ Same shape as set_video_root above — the Music app's own entry point,
+ added later (docs/musicbay.md's original "no root, works over the
+ whole shared tree" simplification didn't hold up against a real messy
+ library). `path=""` clears it — the Music tab then asks for one to be
+ chosen before anything (including tag/cover enrichment) runs, rather
+ than defaulting to the whole shared index.
+ """
+ roster = _roster(state)
+ ctx = _group_ctx(state, group_id)
+ await roster.set_audio_root(group_id, path, set_by=state.get("node_user_id", ""))
+ ctx["audio_root"] = path
+ log.info("Music root for group %s: %r", group_id[:8], path)
+ if path:
+ enrich_fn = state.get("enrich_audio_root_fn")
+ if enrich_fn:
+ asyncio.ensure_future(enrich_fn(group_id))
+ return {"path": path, "group_id": group_id}
+
+
# ── Scan settings ────────────────────────────────────────────────────────────
async def set_scan_settings(state: dict, group_id: str, reconcile_interval_secs: float,