Skip to content

fix(dlna): rebuild the worker's resources on a profile switch#413

Merged
InstaZDLL merged 2 commits into
mainfrom
fix/dlna-profile-switch
Jul 19, 2026
Merged

fix(dlna): rebuild the worker's resources on a profile switch#413
InstaZDLL merged 2 commits into
mainfrom
fix/dlna-profile-switch

Conversation

@InstaZDLL

@InstaZDLL InstaZDLL commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #399.

DlnaResources (the worker's pool + artwork dirs) was only ever rebuilt from the boot path and dlna_set_config. switch_profile never touched it, so a running DLNA server:

  1. kept exposing the previous profile's library to the LAN after a switch — a privacy-adjacent surprise, since switching profiles is often exactly how a user changes what's exposed;
  2. then had its pool closed out from under it once activate_profile dropped the old profile, so every subsequent /stream/<id> and /art/<hash> request failed against a closed pool.

switch_profile now rebuilds DlnaResources from the newly-activated profile and pushes them through DlnaServer::start — but only when state.dlna.status().await.running is 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::start already tears down and rebinds on every Start), so this restarts the listener + SSDP announce, same as a manual reconfigure.

Test plan

  • cargo check -p waveflow --all-targets — clean, no warnings
  • Manual: enable DLNA, switch profiles, confirm a controller (or curl against /ContentDirectory/control) sees the new profile's library and /stream/<id> no longer 500s

Summary by CodeRabbit

  • Améliorations
    • Le service DLNA actualise désormais automatiquement ses ressources lors d’un changement de profil, lorsqu’il est déjà actif.
    • Le changement de profil continue de fonctionner même si la génération des ressources DLNA échoue.

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
@InstaZDLL InstaZDLL added scope: backend Rust/Tauri backend (src-tauri/) type: fix Bug fix size: s 10-50 lines labels Jul 19, 2026
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@InstaZDLL, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 226f0224-765e-4bac-96c1-2b8701b8955e

📥 Commits

Reviewing files that changed from the base of the PR and between 547a230 and 8aa924c.

📒 Files selected for processing (1)
  • src-tauri/crates/app/src/commands/profile.rs
📝 Walkthrough

Walkthrough

Le 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 build_resources décrit également son appel depuis switch_profile.

Changes

Cycle de vie DLNA et profils

Layer / File(s) Summary
Reconstruction DLNA après changement de profil
src-tauri/crates/app/src/commands/profile.rs, src-tauri/crates/app/src/commands/dlna.rs
switch_profile reconstruit les ressources et redémarre le worker DLNA s’il fonctionne ; l’échec est journalisé sans interrompre la commande. La documentation de build_resources reflète ce nouveau point d’appel.

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
Loading

Possibly related PRs

  • InstaZDLL/WaveFlow#398 : introduit le mécanisme de leases utilisé par la reconstruction des ressources DLNA.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Le changement couvre le rebuild de DlnaResources au switch de profil, mais pas l'arrêt de DLNA à la désactivation ni la validation UPnP demandés. Ajoutez le cas deactivate_profile, stoppez DLNA avant remplacement si nécessaire, puis vérifiez le comportement avec un client UPnP réel.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Le titre Conventional Commits décrit bien le rebuild des ressources DLNA lors d'un switch de profil.
Description check ✅ Passed La description reprend le résumé, le plan de test et le lien vers #399; seul le bloc de clôture des issues reste partiellement rempli.
Out of Scope Changes check ✅ Passed Les seules modifications semblent directement liées au correctif DLNA, sans ajout fonctionnel hors périmètre visible.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dlna-profile-switch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@InstaZDLL

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between c6a7694 and 547a230.

📒 Files selected for processing (2)
  • src-tauri/crates/app/src/commands/dlna.rs
  • src-tauri/crates/app/src/commands/profile.rs

Comment thread src-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.
@InstaZDLL
InstaZDLL merged commit 3111d48 into main Jul 19, 2026
14 checks passed
@InstaZDLL
InstaZDLL deleted the fix/dlna-profile-switch branch July 19, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: backend Rust/Tauri backend (src-tauri/) size: s 10-50 lines type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DLNA worker keeps serving the previous profile after a profile switch

1 participant