fix(dlna): rebuild the worker's resources on a profile switch#413
Conversation
The DLNA worker snapshotted the active profile's pool + artwork dirs into DlnaResources only at server start (dlna_set_config / boot), never on switch_profile. A running server therefore kept exposing the previous profile's library to the LAN after a switch, and its pool went stale the moment activate_profile closed the old one — every subsequent /stream/<id> and /art/<hash> request then failed against a closed pool. switch_profile now rebuilds DlnaResources from the newly-activated profile and pushes them through DlnaServer::start whenever status().running is true. Gated on the worker's actual runtime state rather than the persisted dlna.enabled flag, so a switch can't accidentally start a server the user turned off. Fixes #399
|
Warning Review limit reached
Next review available in: 56 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughLe changement de profil rafraîchit désormais le worker DLNA actif avec les ressources du nouveau profil et sa configuration persistée. La documentation de ChangesCycle de vie DLNA et profils
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant switch_profile
participant DLNA_worker
participant build_resources
participant Config_store
switch_profile->>DLNA_worker: vérifier le statut running
switch_profile->>build_resources: reconstruire les ressources du nouveau profil
switch_profile->>Config_store: charger la configuration DLNA
switch_profile->>DLNA_worker: redémarrer avec la configuration et les ressources
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. 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 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
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 `@src-tauri/crates/app/src/commands/profile.rs`:
- Around line 184-187: In the Err branch handling build_resources failure after
the profile switch, call state.dlna.stop() before logging the warning. Ensure
the failed rebuild leaves no stale DLNA worker or server running, while
preserving the existing error log.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 5a618391-ff96-46d5-b8e6-a1dc6f33c962
📒 Files selected for processing (2)
src-tauri/crates/app/src/commands/dlna.rssrc-tauri/crates/app/src/commands/profile.rs
If build_resources errored after a profile switch, the DLNA worker was left running with the OLD profile's DlnaResources — whose pool activate_profile had already closed a few lines above. Every subsequent /stream and /art request would then silently fail against a closed pool instead of the worker either serving the new profile or being stopped. Call state.dlna.stop() in that error branch so a failed rebuild fails closed instead of leaving a broken server behind.
Summary
Fixes #399.
DlnaResources(the worker's pool + artwork dirs) was only ever rebuilt from the boot path anddlna_set_config.switch_profilenever touched it, so a running DLNA server:activate_profiledropped the old profile, so every subsequent/stream/<id>and/art/<hash>request failed against a closed pool.switch_profilenow rebuildsDlnaResourcesfrom the newly-activated profile and pushes them throughDlnaServer::start— but only whenstate.dlna.status().await.runningis true, so a switch can't accidentally start a server the user has turned off. There's no lighter "just swap the pool" path on the worker (WorkerState::startalready tears down and rebinds on everyStart), so this restarts the listener + SSDP announce, same as a manual reconfigure.Test plan
cargo check -p waveflow --all-targets— clean, no warningscurlagainst/ContentDirectory/control) sees the new profile's library and/stream/<id>no longer 500sSummary by CodeRabbit