fix(request): restore media status correctly when deleting requests#3064
Conversation
📝 WalkthroughWalkthroughRefactors subscriber logic to restore DELETED media status when prior completed requests exist; adds integration tests verifying status restoration and preservation across non-4k and 4k deletion scenarios. ChangesMedia Status Restoration on Request Deletion
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 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.
Pull request overview
This PR adjusts request-deletion behavior so that when a request is deleted, the parent Media status is restored based on active requests only, and (when relevant) returns to DELETED if historical completed requests still exist—addressing incorrect status lingering after re-request/delete flows for deleted media.
Changes:
- Update
MediaRequestSubscriber.handleRemoveParentUpdateto consider only non-completed/non-declined requests as “active” when deciding whether to resetMedia.status/status4k. - When resetting status, restore to
DELETEDif any completed requests exist for that quality tier; otherwise restore toUNKNOWN. - Add integration tests covering restoration to
DELETEDvsUNKNOWNand ensuring status is not reset when other active requests remain.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| server/subscriber/MediaRequestSubscriber.ts | Refines request-removal status reset logic to ignore stale completed/declined requests and restore DELETED vs UNKNOWN based on completion history (also for 4K). |
| server/routes/request.test.ts | Adds integration tests covering the reported lifecycle regression and expected status restoration behavior on request deletion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@server/subscriber/MediaRequestSubscriber.ts`:
- Around line 955-960: Rename the misnamed boolean hasActiveNonFk to
hasActiveNon4k to correctly indicate it's checking for non-4k requests and to
match the existing hasActive4k naming; update the declaration that uses
fullMedia.requests.some(...) and replace all usages/references of hasActiveNonFk
(e.g., the later conditional around line where hasActive4k is used) to the new
hasActiveNon4k identifier so compilation and intent remain consistent in
MediaRequestSubscriber's request-status logic.
🪄 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: ec1980b8-5c8d-4b46-9174-34ff701462d5
📒 Files selected for processing (2)
server/routes/request.test.tsserver/subscriber/MediaRequestSubscriber.ts
Reset media status to DELETED (or UNKNOWN) when the last active request is removed, based on whether completed requests exist
83009b2 to
cb20918
Compare
Description
When a movie is deleted from the media server, its status is set to
DELETEDand existing completed requests remain in the database. If a new request is then created for that media and subsequently that request is deleted, the media status would stay asPENDING/REQUESTEDinstead of reverting to DELETED. This happened because previously it counted all remaining requests including stale completed ones when deciding whether to reset the status, and always reset toUNKNOWNregardless of prior history.The PR fixes this by narrowing that check to active requests only and restores to
DELETEDwhen completed requests exist (indicating the media was previously downloaded), orUNKNOWNwhen there is no prior history.How Has This Been Tested?
DELETED.UNKNOWNserver/routes/request.test.tsScreenshots / Logs (if applicable)
Checklist:
pnpm buildpnpm i18n:extractSummary by CodeRabbit
Bug Fixes
Tests