diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-29 15:12:32 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-29 15:12:32 +0200 |
| commit | 5a88f8d7a0a35b0c75b0a56d0f6fce1d0a495c12 (patch) | |
| tree | cbc0a8207885476cd0d331db399536c259ca4f80 /packages/meshbay-node/tests/test_rename_reenrichment.py | |
| parent | be57cf9c3b499c8e59a94d13059f16f1456fcae1 (diff) | |
| parent | 71b7a310ce938f072fe20f27eeeadd40685f1ad1 (diff) | |
| download | meshbay-5a88f8d7a0a35b0c75b0a56d0f6fce1d0a495c12.tar.gz | |
Merge branch 'fix/videos-tmdb-matching'
Diffstat (limited to 'packages/meshbay-node/tests/test_rename_reenrichment.py')
| -rw-r--r-- | packages/meshbay-node/tests/test_rename_reenrichment.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_rename_reenrichment.py b/packages/meshbay-node/tests/test_rename_reenrichment.py index 87e0d1a..7a77368 100644 --- a/packages/meshbay-node/tests/test_rename_reenrichment.py +++ b/packages/meshbay-node/tests/test_rename_reenrichment.py @@ -22,6 +22,7 @@ from meshbay_common.crypto import generate_gek from meshbay_node.config import Config, HubConfig, NodeConfig, GroupConfig, KeystoreConfig from meshbay_node.daemon import NodeDaemon from meshbay_node.indexer import DirectoryIndexer +from meshbay_node.media_cache import MediaCache from conftest import one_root @@ -115,6 +116,61 @@ async def test_a_renamed_file_gets_re_enriched(tmp_path): "from ever being title-parsed") +async def test_a_rename_drops_the_stale_cached_tmdb_match(tmp_path): + """ + A rename re-derives the title, which can change the correct TMDB match + — but media_cache.file_tmdb is keyed by content hash, unchanged by a + rename, so without an explicit clear the old name's match sticks + forever. (An explicit "Fix match" correction is kept — covered by + test_media_cache.py's clear_file_tmdb tests.) + """ + group_id = "a" * 32 + shared = tmp_path / "shared" + shared.mkdir() + old_path = shared / "old.frontier.3.2001.mkv" + old_path.write_bytes(b"not a real video, just needs to be indexed as one") + + config = Config( + hub=HubConfig(url="http://localhost:9999", username="testuser"), + node=NodeConfig(quic_port=_free_port(), ui_port=_free_port()), + groups=[GroupConfig( + id=group_id, name="test-group", shared_dir=str(shared), + visibility="private", quic_port=29018, + )], + keystore=KeystoreConfig(path=tmp_path / "keystore.enc"), + data_dir=tmp_path / "data", + ) + daemon = NodeDaemon(config) + daemon._broadcast_coalesce_secs = 0.01 + daemon._enricher = _SpyEnricher() + daemon._roster = _StubRoster() + media_cache = MediaCache(db_path=tmp_path / "media_cache.db") + await media_cache.open() + daemon._media_cache = media_cache + + indexer = DirectoryIndexer( + roots=one_root(shared), group_id=group_id, + sk_node=Ed25519PrivateKey.generate(), gek=generate_gek(), + on_change=daemon._on_index_change) + await indexer.initial_scan() + await daemon._on_index_change(indexer) + await asyncio.sleep(0.05) + + file_id = next(iter(indexer.index.entries)).id + await media_cache.set_file_tmdb(file_id, "201", "movie") # the wrong match + + old_path.rename(shared / "old.frontier.iii.2001.mkv") + assert await indexer.reconcile() + for _ in range(30): + if await media_cache.get_file_tmdb(file_id) is None: + break + await asyncio.sleep(0.02) + + assert await media_cache.get_file_tmdb(file_id) is None, ( + "a rename must drop the auto-resolved match so it re-resolves") + await media_cache.close() + + async def test_an_unrelated_update_does_not_re_trigger_enrichment(tmp_path): """ The other half of the same fix: an update whose name/path did *not* |