fix: remove orphaned media entries when all requests are deleted#2880
fix: remove orphaned media entries when all requests are deleted#2880Kenshin9977 wants to merge 1 commit intoseerr-team:developfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded a static Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@server/subscriber/MediaRequestSubscriber.ts`:
- Around line 45-49: The reset branch that computes the new status for the
"no-request" side must honor the ACTIVE_STATUSES set instead of only preserving
MediaStatus.AVAILABLE; update the logic in MediaRequestSubscriber.ts so when
computing the new status for the no-request side you only set it to
MediaStatus.UNKNOWN if the current status is not in ACTIVE_STATUSES (i.e.,
preserve MediaStatus.PARTIALLY_AVAILABLE and MediaStatus.PROCESSING), and adjust
the condition that currently checks for equality with MediaStatus.AVAILABLE to
use ACTIVE_STATUSES.has(currentStatus) instead; add regression tests that delete
the last request for media in PROCESSING and PARTIALLY_AVAILABLE states to
ensure they do not become UNKNOWN.
🪄 Autofix (Beta)
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
Run ID: 59e51cee-d814-4a31-98b7-b7b25a1b70f2
📒 Files selected for processing (1)
server/subscriber/MediaRequestSubscriber.ts
8f0006c to
d12a9d6
Compare
When a user deletes the last request associated with a media entry, the media record was left in the database with status UNKNOWN. This orphaned entry prevented users from submitting a new request for the same title, as Seerr still treated it as an existing item. Now, `handleRemoveParentUpdate()` checks whether the media has any remaining requests and whether it is in an active state (AVAILABLE, PARTIALLY_AVAILABLE, or PROCESSING). If no requests remain and the media is not active, the entry is removed entirely, allowing users to re-request the title cleanly. Media that is already available on disk is never removed — only genuinely orphaned entries are cleaned up. > This pull request was authored with AI assistance.
d12a9d6 to
75177a2
Compare
|
Hey, thanks for the PR but this is already handled on When a request is deleted via the request delete endpoint, Additionally, #2478 already hardened which also fixes the exact issue you mention as now when the media delete endpoint is hit, it preserves the blocklisted media by calling There are also a couple of concerns with the changes here as well:
Please test on But as it stands, this PR introduces regressions in the existing logic for a problem that should already be fixed on develop, so I'll be closing it. |
Description
When a user deletes the last request associated with a media entry, the media record is left orphaned in the database with status
UNKNOWN. This prevents users from submitting a new request for the same title since Seerr still treats it as an existing item.handleRemoveParentUpdate()now removes the media entry entirely when no requests remain and the media is not in an active state (AVAILABLE,PARTIALLY_AVAILABLE, orPROCESSING). Media that is already available on disk is never removed.Also aligns the status-reset branch with the same
ACTIVE_STATUSESset to avoid resettingPROCESSINGorPARTIALLY_AVAILABLEmedia toUNKNOWN.How Has This Been Tested?
Manual testing on a self-hosted instance with orphaned media entries. Verified:
Checklist:
pnpm buildpnpm i18n:extractSummary by CodeRabbit
Bug Fixes
Refactor