From 15c52d91f2efa73f3d1b6b06afed840fada29d8e Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sun, 6 Sep 2026 02:46:56 +0200 Subject: fix(node): prevent watchdog from overwriting index entries with duplicate content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The real-time watchdog path lacked the duplicate-content guard that reconciliation already had. When a file with identical content appeared (e.g. browser download appending " (2)"), add_entry overwrote the original's index entry — making it vanish from the file list despite still being on disk. Now check get_entry before adding, matching the reconciliation logic. Co-Authored-By: Claude Opus 4.6 --- packages/meshbay-node/src/meshbay_node/indexer/indexer.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'packages/meshbay-node/src/meshbay_node') diff --git a/packages/meshbay-node/src/meshbay_node/indexer/indexer.py b/packages/meshbay-node/src/meshbay_node/indexer/indexer.py index 8376c23..b0a8e50 100644 --- a/packages/meshbay-node/src/meshbay_node/indexer/indexer.py +++ b/packages/meshbay-node/src/meshbay_node/indexer/indexer.py @@ -805,9 +805,15 @@ class DirectoryIndexer: if not deleted: entry = await self._hash_or_cached(root, file_path) if entry: - self._index.add_entry(entry) - log.debug("Indexed: %s (%s, %d bytes)", - file_path.name, entry.id[:8], entry.size) + existing = self._index.get_entry(entry.id) + if existing is not None: + log.debug("Watchdog: %s duplicates content already " + "indexed as %s/%s — leaving the index alone", + file_path.name, existing.path, existing.name) + else: + self._index.add_entry(entry) + log.debug("Indexed: %s (%s, %d bytes)", + file_path.name, entry.id[:8], entry.size) self._index.version = int(time.time()) if self.on_change: -- cgit v1.2.3