mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 21:17:37 +03:00
Don't import invalid .nsp
files
This commit is contained in:
parent
6a550dab77
commit
2c860edeb5
4 changed files with 9 additions and 4 deletions
|
@ -38,13 +38,13 @@ func IsPlaylist(filePath string) bool {
|
|||
func (s *playlists) ImportFile(ctx context.Context, dir string, fname string) (*model.Playlist, error) {
|
||||
pls, err := s.parsePlaylist(ctx, fname, dir)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error parsing playlist", "playlist", fname, err)
|
||||
log.Error(ctx, "Error parsing playlist", "path", filepath.Join(dir, fname), err)
|
||||
return nil, err
|
||||
}
|
||||
log.Debug("Found playlist", "name", pls.Name, "lastUpdated", pls.UpdatedAt, "path", pls.Path, "numTracks", len(pls.Tracks))
|
||||
err = s.updatePlaylist(ctx, pls)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error updating playlist", "playlist", fname, err)
|
||||
log.Error(ctx, "Error updating playlist", "path", filepath.Join(dir, fname), err)
|
||||
}
|
||||
return pls, err
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package criteria
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
|
@ -71,6 +72,8 @@ func (c *Criteria) UnmarshalJSON(data []byte) error {
|
|||
c.Expression = Any(aux.Any)
|
||||
} else if len(aux.All) > 0 {
|
||||
c.Expression = All(aux.All)
|
||||
} else {
|
||||
return errors.New("invalid criteria json. missing rules (key 'all' or 'any')")
|
||||
}
|
||||
c.Sort = aux.Sort
|
||||
c.Order = aux.Order
|
||||
|
|
|
@ -226,7 +226,10 @@ func (r *playlistRepository) refreshSmartPlaylist(pls *model.Playlist) bool {
|
|||
}
|
||||
|
||||
func (r *playlistRepository) addCriteria(sql SelectBuilder, c criteria.Criteria) SelectBuilder {
|
||||
sql = sql.Where(c.ToSql()).Limit(uint64(c.Limit)).Offset(uint64(c.Offset))
|
||||
sql = sql.Where(c.ToSql())
|
||||
if c.Limit > 0 {
|
||||
sql = sql.Limit(uint64(c.Limit)).Offset(uint64(c.Offset))
|
||||
}
|
||||
if order := c.OrderBy(); order != "" {
|
||||
sql = sql.OrderBy(order)
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ func (s *playlistImporter) processPlaylists(ctx context.Context, dir string) int
|
|||
}
|
||||
pls, err := s.pls.ImportFile(ctx, dir, f.Name())
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error parsing playlist", "playlist", f.Name(), err)
|
||||
continue
|
||||
}
|
||||
if pls.IsSmartPlaylist() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue