feat(library): a missing file stays in the playlist, greyed and unplayable — #2527
Every browse, discover and mix query filters missing_since, so a track
whose file vanished disappears from the places Minstrel chooses music.
A playlist is different: the entry is there because the user put it
there, and silently dropping it rewrites their list behind their back.
So playlists keep the row and mark it instead. ListPlaylistTracks now
carries missing_since (still deliberately unfiltered), the service
layer surfaces it as PlaylistTrack.Unavailable, and the wire gains
"unavailable" on each entry.
A missing entry also loses its stream_url. Refusing to hand out a URL
that cannot serve is stronger than trusting every client to honour the
flag, and "stream_url": null is a shape the clients already model --
PlaylistWire.streamUrl is documented nullable for the track-removed
case -- so an older build degrades to "present but not playable" with
no change.
Nothing is deleted here and nothing should be: the row, its play
history, its likes and its taste contribution all survive a file going
missing, because the file may come back (and #2528 will adopt it if it
comes back renamed).
Also corrects two comments that had drifted into lying. delete.go still
claimed the file-gone case was NOT auto-reconciled and told admins to
delete rows by hand -- untrue since f6d1cf24, and that exact staleness
is what produced drift #572. It now says what DeleteTrackFile really is:
the destructive admin action, which CASCADEs play_events and likes, and
is emphatically not the missing-file path. watcher.go claimed the
safety-net scan "covers anything missed"; the walk only covers
additions, and it is reconcile that covers removals.
This commit is contained in:
@@ -60,6 +60,11 @@ type playlistTrackView struct {
|
||||
DurationSec int32 `json:"duration_sec"`
|
||||
StreamURL *string `json:"stream_url"`
|
||||
AddedAt string `json:"added_at"`
|
||||
// Unavailable marks an entry whose file is missing from disk (#2527).
|
||||
// The track is still a real, known track — its history and likes are
|
||||
// intact and the file may come back — so the entry keeps its place and
|
||||
// its text; clients render it greyed out and skip over it on playback.
|
||||
Unavailable bool `json:"unavailable"`
|
||||
}
|
||||
|
||||
// playlistDetailView extends playlistRowView with the ordered track list.
|
||||
@@ -472,12 +477,20 @@ func playlistDetailToView(d *playlists.PlaylistDetail) playlistDetailView {
|
||||
AlbumTitle: t.AlbumTitle,
|
||||
DurationSec: t.DurationSec,
|
||||
AddedAt: formatTimestamp(t.AddedAt),
|
||||
Unavailable: t.Unavailable,
|
||||
}
|
||||
if t.TrackID != nil {
|
||||
s := uuidToString(*t.TrackID)
|
||||
v.TrackID = &s
|
||||
url := streamURL(*t.TrackID)
|
||||
v.StreamURL = &url
|
||||
// No stream URL for a missing file. The wire refuses to offer
|
||||
// a URL that cannot serve rather than trusting every client to
|
||||
// honour Unavailable — and `"stream_url": null` is a shape the
|
||||
// clients already handle (the track-removed case), so an older
|
||||
// build degrades to "present but not playable" on its own.
|
||||
if !t.Unavailable {
|
||||
url := streamURL(*t.TrackID)
|
||||
v.StreamURL = &url
|
||||
}
|
||||
}
|
||||
if t.AlbumID != nil {
|
||||
s := uuidToString(*t.AlbumID)
|
||||
|
||||
Reference in New Issue
Block a user