Okay, now let's return original idea of adding songs one by one.
This commit is contained in:
parent
6d4a276dd8
commit
d48972caa0
@ -181,10 +181,7 @@ func (pw *PlaylistLogWatcher) Watch(playlistPath string, n int) (err error) {
|
||||
|
||||
pw.watcher.WatchForMask(pw.changed, watcher.ModIgnMask)
|
||||
|
||||
lastPlayedCache, err = icecastLastPlayedSongs(playlistPath, n)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "cannot instantiate last played cache")
|
||||
}
|
||||
lastPlayedCache = make([]Song, 0, n)
|
||||
|
||||
go func() {
|
||||
for {
|
||||
@ -192,8 +189,12 @@ func (pw *PlaylistLogWatcher) Watch(playlistPath string, n int) (err error) {
|
||||
case mask := <-pw.changed:
|
||||
if mask&syscall.IN_MODIFY > 0 {
|
||||
lastPlayedCacheMutex.Lock()
|
||||
if songs, err := icecastLastPlayedSongs(playlistPath, n); err == nil && len(songs) > 0 {
|
||||
lastPlayedCache = songs
|
||||
if songs, err := icecastLastPlayedSongs(playlistPath, 1); err == nil && len(songs) > 0 {
|
||||
if len(lastPlayedCache) == n {
|
||||
lastPlayedCache = append(lastPlayedCache[1:], songs...)
|
||||
} else {
|
||||
lastPlayedCache = append(lastPlayedCache, songs...)
|
||||
}
|
||||
}
|
||||
lastPlayedCacheMutex.Unlock()
|
||||
} else if mask&syscall.IN_IGNORED > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user