From 211ace6cc0168647e00bcc20a909aead50b8ad0a Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Mon, 14 Sep 2026 02:35:45 +0200 Subject: fix(node): an added root is served before it is scanned Adding a large directory to a running group made the reload await the scan of the new root before putting the new RootSet in the group's context, holding _reload_lock the whole time. For the hours a large drive takes to hash, the node served the old set: - a file request under the new root got None from entry_abs_path and the handler died on None.exists() without replying; - a writable/removable toggle answered with the live table, still the old one, so the directory vanished from the operator's settings; - reconcile saw every file the scan had not reached as a missed event and hashed it again on the same executor, rewriting progress under the scan. retarget now applies the set, the roots table and the watcher first, and with wait=False scans the added roots in the background; the daemon swaps ctx["roots"] before calling it. A scan lock shared by the initial scan, added-root scans and reconcile makes the reconcile loop sit out a running scan without backing off. Every transport site that resolves an entry answers ROOT_NOT_SERVED instead of crashing, and a delete keeps the entry. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01T6jPTeocXA1BePekdsgPya --- packages/meshbay-node/src/meshbay_node/roots.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'packages/meshbay-node/src/meshbay_node/roots.py') diff --git a/packages/meshbay-node/src/meshbay_node/roots.py b/packages/meshbay-node/src/meshbay_node/roots.py index 410fe68..7854e28 100644 --- a/packages/meshbay-node/src/meshbay_node/roots.py +++ b/packages/meshbay-node/src/meshbay_node/roots.py @@ -384,6 +384,11 @@ class RootSet: return out +# What a transport answers when `entry_abs_path` gives None: the entry is in the +# index but its root is ejected, unplugged, or not in the set being served. +ROOT_NOT_SERVED = "File not available: its folder is not readable right now" + + def entry_abs_path(roots: RootSet, entry) -> Path | None: """ Where an index entry actually lives, or None if its root is gone. -- cgit v1.2.3