summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/indexer/group_index.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-24 14:33:38 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-24 14:33:38 +0200
commit317f09328ed8bf20148b707470c9b0fe82e59575 (patch)
treeba8daf5dcf050d44b7b0e766babbfda8fadac59f /packages/meshbay-node/src/meshbay_node/indexer/group_index.py
parentb6e2dcea65124673da047f9b3c92bc5e25980d63 (diff)
parent0b0da86f1f9d6f0b1a27b5e1e1658c42de9f356a (diff)
downloadmeshbay-317f09328ed8bf20148b707470c9b0fe82e59575.tar.gz
Merge branch 'docs/mediacenter-videos-app': Videos group app
Poster grid / flat list browsing, TMDB metadata enrichment, thumbnail generation and caching, season-specific overviews, manual match correction, and the create-group wizard's app-selection step. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LAmyXtc6dAADsH23ydXQpY
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/indexer/group_index.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/indexer/group_index.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/indexer/group_index.py b/packages/meshbay-node/src/meshbay_node/indexer/group_index.py
index ec98667..1ce4e0a 100644
--- a/packages/meshbay-node/src/meshbay_node/indexer/group_index.py
+++ b/packages/meshbay-node/src/meshbay_node/indexer/group_index.py
@@ -78,6 +78,19 @@ class GroupIndex:
def get_entry(self, file_id: str) -> IndexEntry | None:
return self._entries.get(file_id)
+ def get_entry_by_path(self, path: str) -> IndexEntry | None:
+ """
+ Linear scan — entries are keyed by content id, not path, and nothing
+ before the Videos app needed to go the other way (a client always
+ already has the id from index_sync/index_delta). Fine for an
+ on-demand, per-tile lookup against a few thousand entries; revisit
+ if a future caller makes this hot.
+ """
+ for entry in self._entries.values():
+ if entry.path == path:
+ return entry
+ return None
+
@property
def entries(self) -> list[IndexEntry]:
return list(self._entries.values())
@@ -205,16 +218,34 @@ class GroupIndex:
# ── Delta ─────────────────────────────────────────────────────────────────
def diff(self, previous: "GroupIndex") -> IndexDelta:
- """Compute what changed since a previous version of this index."""
+ """
+ Compute what changed since a previous version of this index.
+
+ A shared id whose entry object now compares unequal (field-by-field,
+ via IndexEntry's dataclass-generated __eq__) is an update, not an
+ addition — the Videos app's async enrichment (duration, thumb_hash,
+ title, ...) replaces an existing entry's fields after the fact via
+ `add_entry`, which never introduces a new id. This only works
+ because that replacement always constructs a *new* IndexEntry object
+ (`dataclasses.replace`, never in-place attribute mutation) — mutating
+ the same object in place would also mutate `previous`'s copy, since
+ entries_by_id() is a shallow dict copy, and the two would always
+ compare equal.
+ """
prev_ids = set(previous._entries)
curr_ids = set(self._entries)
additions = [self._entries[i] for i in curr_ids - prev_ids]
deletions = list(prev_ids - curr_ids)
+ updates = [
+ self._entries[i] for i in curr_ids & prev_ids
+ if self._entries[i] != previous._entries[i]
+ ]
return IndexDelta(
base_version=previous.version,
version=self.version,
additions=additions,
deletions=deletions,
+ updates=updates,
)