fix(playlists): a restored playlist draws its collage again instead of showing a broken image (#8105)

A collage is a file in the data directory, which the backup doesn't carry,
but playlists.cover_path travelled, so a restored playlist pointed at a file
that wasn't there and its tile showed a broken image until someone edited it.

- The backup leaves cover_path out, so a restored playlist starts with none.
- The nightly rebuild (and the catch-up at startup) draws each person's own
  playlist collages again from their albums' current covers, so one drawn
  before the art arrived fills in later.
- The cover endpoint draws a collage whose file has gone missing, rather
  than answering 404.
- SetPlaylistCover only bumps updated_at when the path changes, so a redraw
  isn't a change to the playlist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 23:55:30 -05:00
co-authored by Claude Opus 5.5
parent 436a970f7b
commit dbf39f90f8
7 changed files with 117 additions and 3 deletions
+13
View File
@@ -4,7 +4,9 @@ import (
"context"
"errors"
"fmt"
"io/fs"
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
@@ -452,6 +454,17 @@ func (h *handlers) handleGetPlaylistCover(w http.ResponseWriter, r *http.Request
return
}
full := filepath.Join(h.dataDir, *detail.CoverPath)
if _, err := os.Stat(full); errors.Is(err, fs.ErrNotExist) {
// The row names a collage the data directory no longer holds (it
// was lost or moved without the database). Draw it again rather
// than answer with a broken image.
rel, gerr := playlists.GenerateCollage(r.Context(), h.pool, playlistID, h.dataDir)
if gerr != nil || rel == "" {
writeErr(w, &apierror.Error{Status: 404, Code: "not_found", Message: "no cover"})
return
}
full = filepath.Join(h.dataDir, rel)
}
// Playlist collages recompute when the playlist's tracks change
// (system playlists re-rendered on rebuild, user playlists when
// modified). 5 minutes is short enough for normal edits to feel