From 84aa73e89cfe486c62317f761dcf87d7845eb4f7 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Wed, 26 Aug 2026 15:36:23 +0200 Subject: fix(video): TMDB match cache never invalidated on movie<->show reclassification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The real reason a node restart alone didn't fix already-indexed entries after the previous commit's enrichment change: _do_media_meta_request checked media_cache's file->tmdb mapping (keyed by content hash) and trusted it unconditionally, before ever comparing it against the file's *current* movie/show classification. A file whose season/episode changed on a later scan — exactly what the Specials-folder fix does, for every file it reclassifies from "movie" to "tv" — kept answering with its stale, wrong-kind-of-match forever, since nothing about a reclassification touches this cache or its key. Now falls through to a fresh search whenever the cached media_type disagrees with what the entry resolves to right now, rather than trusting a mapping that predates the file's current classification. --- .../src/meshbay_node/transport/webrtc_server.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'packages/meshbay-node/src/meshbay_node/transport') diff --git a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py index 724527b..2b3e3ee 100644 --- a/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py +++ b/packages/meshbay-node/src/meshbay_node/transport/webrtc_server.py @@ -2914,8 +2914,20 @@ class WebRTCPeerSession: meta = None tmdb_id = None if cached is not None: - tmdb_id, media_type = cached - meta = await media_cache.get_tmdb_meta(tmdb_id, media_type) + cached_tmdb_id, cached_media_type = cached + # Trustworthy only if it still agrees with what this file + # resolves to *now*. season/episode come from index-time + # enrichment (enrich.py), which can reclassify a file between + # movie and show on a later scan without this cache knowing — + # it is keyed by the file's content hash alone, which a + # reclassification never changes. Found live: an enrichment fix + # to a Specials-folder bug reclassified hundreds of files from + # "movie" to "tv", and every one kept answering with its + # stale movie-era match forever, because this was trusted + # before ever comparing media_type against the current one. + if cached_media_type == media_type: + tmdb_id = cached_tmdb_id + meta = await media_cache.get_tmdb_meta(tmdb_id, media_type) if meta is None: result, ratio = await self._tmdb_search(tmdb_client, entry, is_show) -- cgit v1.2.3