summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-06 02:46:56 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-06 02:46:56 +0200
commit15c52d91f2efa73f3d1b6b06afed840fada29d8e (patch)
tree224cdb811990352ceed5e82cb3c0d9146ad6510e /packages/meshbay-node/src
parent9372ea95e4bd4da36c22438afb58f15717af198c (diff)
downloadmeshbay-15c52d91f2efa73f3d1b6b06afed840fada29d8e.tar.gz
fix(node): prevent watchdog from overwriting index entries with duplicate content
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 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/src')
-rw-r--r--packages/meshbay-node/src/meshbay_node/indexer/indexer.py12
1 files changed, 9 insertions, 3 deletions
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: