fix(smartplaylist): don't let invalid rules hide all playlists - #6316
Empty nested groups were saved as {} and could not be read back, failing
every playlist query. Drop them while parsing, and log and skip unreadable
rules stored in the DB instead of failing the whole listing.
Signed-off-by: DualFroz <me@dualfroz.com>
This commit is contained in:
1 parent
46e0546b86
commit
45e13950f3
4 files changed
+74
-2
No files matched your search
@@ -27,8 +27,13 @@ type dbPlaylist struct {
|
||||
}
|
||||
|
||||
func (p *dbPlaylist) PostScan() error {
|
||||
if p.Rules.String != "" {
|
||||
return json.Unmarshal([]byte(p.Rules.String), &p.Playlist.Rules)
|
||||
if p.Rules.String == "" {
|
||||
return nil
|
||||
}
|
||||
// Rules come from clients and .nsp files, so a bad one must not fail every query listing it
|
||||
if err := json.Unmarshal([]byte(p.Rules.String), &p.Playlist.Rules); err != nil {
|
||||
log.Warn("Ignoring invalid smart playlist rules", "playlist", p.Name, "id", p.ID, "rules", p.Rules.String, err)
|
||||
p.Playlist.Rules = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user