🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Don't refresh smart playlists when generating covers
Deluandf0f140f9f91
diff --git a/cmd/pls.go b/cmd/pls.goindex 28fdf7532..1d390c1e8 100644--- a/cmd/pls.go+++ b/cmd/pls.go@@ -39,7 +39,7 @@ func runExporter() {sqlDB := db.Db()ds := persistence.New(sqlDB)ctx := auth.WithAdminUser(context.Background(), ds)- playlist, err := ds.Playlist(ctx).GetWithTracks(playlistID)+ playlist, err := ds.Playlist(ctx).GetWithTracks(playlistID, true)if err != nil && !errors.Is(err, model.ErrNotFound) {log.Fatal("Error retrieving playlist", "name", playlistID, err)}@@ -49,7 +49,7 @@ func runExporter() {log.Fatal("Error retrieving playlist", "name", playlistID, err)}if len(playlists) > 0 {- playlist, err = ds.Playlist(ctx).GetWithTracks(playlists[0].ID)+ playlist, err = ds.Playlist(ctx).GetWithTracks(playlists[0].ID, true)if err != nil {log.Fatal("Error retrieving playlist", "name", playlistID, err)}diff --git a/core/archiver.go b/core/archiver.goindex a66478099..db22d97e8 100644--- a/core/archiver.go+++ b/core/archiver.go@@ -56,7 +56,7 @@ func (a *archiver) ZipArtist(ctx context.Context, id string, format string, bitr}func (a *archiver) ZipPlaylist(ctx context.Context, id string, format string, bitrate int, out io.Writer) error {- pls, err := a.ds.Playlist(ctx).GetWithTracks(id)+ pls, err := a.ds.Playlist(ctx).GetWithTracks(id, true)if err != nil {log.Error(ctx, "Error loading mediafiles from playlist", "id", id, err)return errdiff --git a/core/artwork/reader_playlist.go b/core/artwork/reader_playlist.goindex f42d1249b..aa0304e9d 100644--- a/core/artwork/reader_playlist.go+++ b/core/artwork/reader_playlist.go@@ -45,7 +45,7 @@ func (a *playlistArtworkReader) LastUpdated() time.Time {func (a *playlistArtworkReader) Reader(ctx context.Context) (io.ReadCloser, string, error) {var ff []sourceFunc- pl, err := a.a.ds.Playlist(ctx).GetWithTracks(a.pl.ID)+ pl, err := a.a.ds.Playlist(ctx).GetWithTracks(a.pl.ID, false)if err == nil {ff = append(ff, a.fromGeneratedTile(ctx, pl.Tracks))}diff --git a/core/playlists.go b/core/playlists.goindex 65878b044..a538986dd 100644--- a/core/playlists.go+++ b/core/playlists.go@@ -200,7 +200,7 @@ func (s *playlists) Update(ctx context.Context, playlistID string,var err errorrepo := tx.Playlist(ctx)if needsTrackRefresh {- pls, err = repo.GetWithTracks(playlistID)+ pls, err = repo.GetWithTracks(playlistID, true)pls.RemoveTracks(idxToRemove)pls.AddTracks(idsToAdd)} else {diff --git a/model/playlist.go b/model/playlist.goindex 9f38aea14..085d3f3c3 100644--- a/model/playlist.go+++ b/model/playlist.go@@ -106,7 +106,7 @@ type PlaylistRepository interface {Exists(id string) (bool, error)Put(pls *Playlist) errorGet(id string) (*Playlist, error)- GetWithTracks(id string) (*Playlist, error)+ GetWithTracks(id string, refreshSmartPlaylist bool) (*Playlist, error)GetAll(options ...QueryOptions) (Playlists, error)FindByPath(path string) (*Playlist, error)Delete(id string) errordiff --git a/persistence/playlist_repository.go b/persistence/playlist_repository.goindex be46d60d3..fe1ecd5e7 100644--- a/persistence/playlist_repository.go+++ b/persistence/playlist_repository.go@@ -129,12 +129,14 @@ func (r *playlistRepository) Get(id string) (*model.Playlist, error) {return r.findBy(And{Eq{"playlist.id": id}, r.userFilter()})}-func (r *playlistRepository) GetWithTracks(id string) (*model.Playlist, error) {+func (r *playlistRepository) GetWithTracks(id string, refreshSmartPlaylist bool) (*model.Playlist, error) {pls, err := r.Get(id)if err != nil {return nil, err}- r.refreshSmartPlaylist(pls)+ if refreshSmartPlaylist {+ r.refreshSmartPlaylist(pls)+ }tracks, err := r.loadTracks(Select().From("playlist_tracks"), id)if err != nil {log.Error(r.ctx, "Error loading playlist tracks ", "playlist", pls.Name, "id", pls.ID, err)diff --git a/persistence/playlist_repository_test.go b/persistence/playlist_repository_test.goindex e0870b435..01672c512 100644--- a/persistence/playlist_repository_test.go+++ b/persistence/playlist_repository_test.go@@ -55,7 +55,7 @@ var _ = Describe("PlaylistRepository", func() {Expect(err).To(MatchError(model.ErrNotFound))})It("returns all tracks", func() {- pls, err := repo.GetWithTracks(plsBest.ID)+ pls, err := repo.GetWithTracks(plsBest.ID, true)Expect(err).To(BeNil())Expect(pls.Name).To(Equal(plsBest.Name))Expect(pls.Tracks).To(HaveLen(2))@@ -85,7 +85,7 @@ var _ = Describe("PlaylistRepository", func() {By("adds repeated songs to a playlist and keeps the order")newPls.AddTracks([]string{"1004"})Expect(repo.Put(&newPls)).To(BeNil())- saved, _ := repo.GetWithTracks(newPls.ID)+ saved, _ := repo.GetWithTracks(newPls.ID, true)Expect(saved.Tracks).To(HaveLen(3))Expect(saved.Tracks[0].MediaFileID).To(Equal("1004"))Expect(saved.Tracks[1].MediaFileID).To(Equal("1003"))diff --git a/server/nativeapi/playlists.go b/server/nativeapi/playlists.goindex 10fe727da..19ebdc717 100644--- a/server/nativeapi/playlists.go+++ b/server/nativeapi/playlists.go@@ -47,7 +47,7 @@ func handleExportPlaylist(ds model.DataStore) http.HandlerFunc {ctx := r.Context()plsRepo := ds.Playlist(ctx)plsId := chi.URLParam(r, "playlistId")- pls, err := plsRepo.GetWithTracks(plsId)+ pls, err := plsRepo.GetWithTracks(plsId, true)if errors.Is(err, model.ErrNotFound) {log.Warn(r.Context(), "Playlist not found", "playlistId", plsId)http.Error(w, "not found", http.StatusNotFound)diff --git a/server/subsonic/playlists.go b/server/subsonic/playlists.goindex 58ce67872..11d43181c 100644--- a/server/subsonic/playlists.go+++ b/server/subsonic/playlists.go@@ -38,7 +38,7 @@ func (api *Router) GetPlaylist(r *http.Request) (*responses.Subsonic, error) {}func (api *Router) getPlaylist(ctx context.Context, id string) (*responses.Subsonic, error) {- pls, err := api.ds.Playlist(ctx).GetWithTracks(id)+ pls, err := api.ds.Playlist(ctx).GetWithTracks(id, true)if errors.Is(err, model.ErrNotFound) {log.Error(ctx, err.Error(), "id", id)return nil, newError(responses.ErrorDataNotFound, "Directory not found")