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)
|
pw.watcher.WatchForMask(pw.changed, watcher.ModIgnMask)
|
||||||
|
|
||||||
lastPlayedCache, err = icecastLastPlayedSongs(playlistPath, n)
|
lastPlayedCache = make([]Song, 0, n)
|
||||||
if err != nil {
|
|
||||||
return errors.Wrap(err, "cannot instantiate last played cache")
|
|
||||||
}
|
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
@ -192,8 +189,12 @@ func (pw *PlaylistLogWatcher) Watch(playlistPath string, n int) (err error) {
|
|||||||
case mask := <-pw.changed:
|
case mask := <-pw.changed:
|
||||||
if mask&syscall.IN_MODIFY > 0 {
|
if mask&syscall.IN_MODIFY > 0 {
|
||||||
lastPlayedCacheMutex.Lock()
|
lastPlayedCacheMutex.Lock()
|
||||||
if songs, err := icecastLastPlayedSongs(playlistPath, n); err == nil && len(songs) > 0 {
|
if songs, err := icecastLastPlayedSongs(playlistPath, 1); err == nil && len(songs) > 0 {
|
||||||
lastPlayedCache = songs
|
if len(lastPlayedCache) == n {
|
||||||
|
lastPlayedCache = append(lastPlayedCache[1:], songs...)
|
||||||
|
} else {
|
||||||
|
lastPlayedCache = append(lastPlayedCache, songs...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lastPlayedCacheMutex.Unlock()
|
lastPlayedCacheMutex.Unlock()
|
||||||
} else if mask&syscall.IN_IGNORED > 0 {
|
} else if mask&syscall.IN_IGNORED > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user