Debug playlist lecture

This commit is contained in:
2025-12-28 15:27:48 +01:00
parent 2f77913caa
commit 02a44e9e75
8 changed files with 125 additions and 8 deletions

View File

@@ -527,7 +527,8 @@ impl WriteHandle {
manager
.rebuild_track_index(&self.playlist.id, &snapshot)
.await;
manager.notify_playlist_changed(&self.playlist.id);
// PK swap uniquement - pas de notification UPnP pour éviter le reload
manager.notify_playlist_pk_updated(&self.playlist.id, old_pk, new_pk);
}
Ok(())

View File

@@ -48,6 +48,9 @@ pub struct PlaylistEvent {
pub enum PlaylistEventKind {
/// La playlist a été modifiée (ajout/suppression/changement de config).
Updated,
/// Cache PK commuté (lazy→real) - pas de changement structurel.
/// N'émet PAS de ContainersUpdated UPnP pour éviter le reload.
PkUpdated { old_pk: String, new_pk: String },
/// Un morceau référencé par la playlist a été servi par le cache audio.
TrackPlayed { cache_pk: String, qualifier: String },
}
@@ -270,6 +273,18 @@ impl PlaylistManager {
self.notify_playlist_event(id, PlaylistEventKind::Updated);
}
/// Notifie que des PK ont été swappés (lazy→real).
/// N'émet PAS de notification UPnP ContainersUpdated pour éviter le reload.
pub(crate) fn notify_playlist_pk_updated(&self, id: &str, old_pk: &str, new_pk: &str) {
self.notify_playlist_event(
id,
PlaylistEventKind::PkUpdated {
old_pk: old_pk.to_string(),
new_pk: new_pk.to_string(),
},
);
}
/// Notifie les callbacks qu'un morceau a été joué pour une playlist donnée.
pub(crate) fn notify_playlist_track_played(
&self,

View File

@@ -55,6 +55,10 @@ pub async fn playlist_events_sse(Query(params): Query<EventsQuery>) -> impl Into
let (kind, cache_pk, qualifier) = match &envelope.event.kind {
PlaylistEventKind::Updated => ("updated", None, None),
PlaylistEventKind::PkUpdated { old_pk: _, new_pk: _ } => {
// PK swap silencieux - envoyer quand même l'événement SSE pour debug/monitoring
("pk_updated", None, None)
}
PlaylistEventKind::TrackPlayed { cache_pk, qualifier } => {
("track_played", Some(cache_pk.as_str()), Some(qualifier.as_str()))
}