Fix playlist cannot be empty via Subsonic API

This commit is contained in:
Deluan 2021-11-05 10:23:45 -04:00
parent 5994c31f4c
commit 0d9dcebf32
4 changed files with 22 additions and 3 deletions

View file

@ -227,6 +227,12 @@ func (s *playlists) Update(ctx context.Context, playlistId string,
if public != nil {
pls.Public = *public
}
// Special case: The playlist is now empty
if len(idxToRemove) > 0 && len(pls.Tracks) == 0 {
if err = repo.Tracks(playlistId).DeleteAll(); err != nil {
return err
}
}
return repo.Put(pls)
})
}