fix(cache): revalidate cached torrent titles - #630
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughCached torrent loading revalidates titles against requested metadata before insertion. Primary-cache status is set only for accepted matching torrents. The parse-cache helper is now named ChangesCached Torrent Validation
Sequence Diagram(s)sequenceDiagram
participant Cache
participant TorrentManager
participant TitleMatcher
Cache->>TorrentManager: provide cached torrent rows
TorrentManager->>TitleMatcher: validate cached titles and metadata
TitleMatcher-->>TorrentManager: accept or reject rows
TorrentManager-->>Cache: store accepted rows and primary-cache state
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@comet/services/orchestration.py`:
- Around line 199-208: Preserve each row’s originating cache media ID through
the deduplication performed by best_rows, rather than deriving primary_cached
from all primary-cache info_hashes. Update the acceptance logic around
primary_cached to set it only when the selected row originated from
self.media_only_id, including the duplicate-hash case where a valid secondary
row replaces an invalid primary row. Add a regression test covering that
scenario.
- Around line 258-261: Update the cached-row filtering condition around
parsed_data.parsed_title to reject rows when no parsed title is present, while
retaining the existing TitleMatcher.matches validation for populated titles.
Align this behavior with filter_worker.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cd33ec79-4088-4baa-9f36-1bb85c338f14
📒 Files selected for processing (2)
comet/services/orchestration.pytests/test_cached_title_revalidation.py
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_cached_title_revalidation.py (1)
135-136: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAssert that the secondary row was retained.
The primary row is intentionally mismatched, so
primary_cached == Falseis expected.assertIndoes not prove that the accepted row came fromsecondary. Assert the retained row metadata againstsecondary. Add a valid/valid duplicate case if this test must directly cover source preservation.Proposed assertion
self.assertIn(duplicate_hash, manager.torrents) + self.assertEqual( + manager.torrents[duplicate_hash]["updatedAt"], + secondary["updated_at"], + ) self.assertFalse(manager.primary_cached)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_cached_title_revalidation.py` around lines 135 - 136, Strengthen the assertions in the cached-title revalidation test by verifying that manager.torrents[duplicate_hash] retains the metadata from secondary, not merely that the hash exists. Keep the expected primary_cached == False assertion, and add a valid/valid duplicate case only if needed to directly verify secondary-source preservation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_cached_title_revalidation.py`:
- Around line 135-136: Strengthen the assertions in the cached-title
revalidation test by verifying that manager.torrents[duplicate_hash] retains the
metadata from secondary, not merely that the hash exists. Keep the expected
primary_cached == False assertion, and add a valid/valid duplicate case only if
needed to directly verify secondary-source preservation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 484a8216-4061-49f2-866e-69e34eadf5c6
📒 Files selected for processing (2)
comet/services/orchestration.pytests/test_cached_title_revalidation.py
🚧 Files skipped from review as they are similar to previous changes (1)
- comet/services/orchestration.py
What changed
Cached torrent rows are now revalidated before they are returned:
TitleMatcherchecks the parsed title and release year against the requested media;parsed_jsonis not trusted as the authority for title matching;primary_cachedis set only after an accepted row from the primary media ID, including when duplicate info hashes are deduplicated across cache IDs.Why
CometNet validates that an IMDb ID exists, but a propagated torrent's title can still be inconsistent with that ID. Because cached rows bypassed live title filtering, a release such as
Into the Spider-Versecould be stored underSpider-Man: Homecomingand continue appearing in results.Tests
uv run pytest tests/test_cached_title_revalidation.py tests/test_orchestration.py tests/test_filtering.py— 19 passeduvx ruff check comet/services/filtering.py comet/services/orchestration.py tests/test_cached_title_revalidation.py tests/test_orchestration.py— passeduv run python -m compileall -q comet— passedThe full suite cannot be collected on this Windows environment because
mediaflow_proxyimports the Unix-onlyfcntlmodule in four existing streaming test modules.Summary by CodeRabbit
Bug Fixes
Tests