diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-07-22 15:15:47 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-07-22 15:15:47 +0200 |
| commit | 26f0033ebb5f8e7c204a042709e3dfa885eac868 (patch) | |
| tree | 6e3c0bbb0525bd295db93a363b28d33f557a0a17 /localBackend.go | |
| parent | d00967aa6e6ce880b5f900e8493fd93092fd36ca (diff) | |
| download | WRMS-26f0033ebb5f8e7c204a042709e3dfa885eac868.tar.gz WRMS-26f0033ebb5f8e7c204a042709e3dfa885eac868.zip | |
fix applyTimeBonus by always using Song pointers
Storing song objects in the Songs slice and using pointers to the
underlying array slots breaks if the underlying array must be grown.
When the array is grown the objects are copied to the new array and
the pointers used in queue point to the old objects.
This causes that Playlist.applyTimeBonus may not correctly apply
to the most recent list of songs.
This is fixed by always using Song pointers.
Diffstat (limited to 'localBackend.go')
| -rw-r--r-- | localBackend.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/localBackend.go b/localBackend.go index cb07ab1..e59bf03 100644 --- a/localBackend.go +++ b/localBackend.go @@ -114,7 +114,7 @@ func (b *LocalBackend) findSongs() { s := NewSong(m.Title(), m.Artist(), "local", p) s.Album = m.Album() s.Year = m.Year() - songs = append(songs, &s) + songs = append(songs, s) return nil }) @@ -129,7 +129,7 @@ func (b *LocalBackend) Play(song *Song, player Player) { player.PlayUri("file://" + song.Uri) } -func (b *LocalBackend) Search(patterns map[string]string) (results []Song) { +func (b *LocalBackend) Search(patterns map[string]string) (results []*Song) { pattern := strings.ToLower(patterns["pattern"]) query := fmt.Sprintf("SELECT * FROM songs WHERE Title LIKE '%%%s%%' OR Artist LIKE '%%%s%%'", |
