From 18e1c169f9b3acccddc33869fdb3b39b6cc12672 Mon Sep 17 00:00:00 2001 From: Deluan Date: Sun, 24 Oct 2021 14:41:08 -0400 Subject: [PATCH] Don't read the whole smart playlist file in memory --- core/playlists.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/playlists.go b/core/playlists.go index 4e13ba1f7..704b1f391 100644 --- a/core/playlists.go +++ b/core/playlists.go @@ -93,13 +93,9 @@ func (s *playlists) newSyncedPlaylist(baseDir string, playlistFile string) (*mod } func (s *playlists) parseNSP(ctx context.Context, pls *model.Playlist, file io.Reader) (*model.Playlist, error) { - content, err := io.ReadAll(file) - if err != nil { - return nil, err - } - pls.Rules = &criteria.Criteria{} - err = json.Unmarshal(content, pls.Rules) + dec := json.NewDecoder(file) + err := dec.Decode(pls.Rules) if err != nil { log.Error(ctx, "Error parsing SmartPlaylist", "playlist", pls.Name, err) return nil, err