add cache warming for album covers to album iterators
This commit is contained in:
@@ -14,6 +14,8 @@ type AlbumIterator interface {
|
||||
}
|
||||
|
||||
type LibraryManager struct {
|
||||
PreCacheCoverFn func(string)
|
||||
|
||||
s *ServerManager
|
||||
albumDetailCache gcache.Cache
|
||||
}
|
||||
@@ -153,6 +155,11 @@ func (r *baseIter) Next() *subsonic.AlbumID3 {
|
||||
}
|
||||
r.prefetched = albums
|
||||
r.prefetchedPos = 1
|
||||
if r.l.PreCacheCoverFn != nil {
|
||||
for _, album := range albums {
|
||||
go r.l.PreCacheCoverFn(album.ID)
|
||||
}
|
||||
}
|
||||
|
||||
return r.prefetched[0]
|
||||
}
|
||||
@@ -277,6 +284,9 @@ func (s *searchIter) addNewAlbums(al []*subsonic.AlbumID3) {
|
||||
continue
|
||||
}
|
||||
s.prefetched = append(s.prefetched, album)
|
||||
if s.l.PreCacheCoverFn != nil {
|
||||
go s.l.PreCacheCoverFn(album.ID)
|
||||
}
|
||||
s.albumIDset[album.ID] = true
|
||||
}
|
||||
}
|
||||
@@ -328,6 +338,9 @@ func (r *randomIter) Next() *subsonic.AlbumID3 {
|
||||
for _, album := range albums {
|
||||
if _, ok := r.albumIDSet[album.ID]; !ok {
|
||||
r.prefetched = append(r.prefetched, album)
|
||||
if r.l.PreCacheCoverFn != nil {
|
||||
go r.l.PreCacheCoverFn(album.ID)
|
||||
}
|
||||
r.albumIDSet[album.ID] = true
|
||||
}
|
||||
}
|
||||
@@ -346,6 +359,9 @@ func (r *randomIter) Next() *subsonic.AlbumID3 {
|
||||
if _, ok := r.albumIDSet[album.ID]; !ok {
|
||||
hitCount++
|
||||
r.prefetched = append(r.prefetched, album)
|
||||
if r.l.PreCacheCoverFn != nil {
|
||||
go r.l.PreCacheCoverFn(album.ID)
|
||||
}
|
||||
r.albumIDSet[album.ID] = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user