When retrieving images from external sources, avoid calling it again if data is already cached locally.

Relates to https://github.com/navidrome/navidrome/issues/2130#issuecomment-1412742918
This commit is contained in:
Deluan
2023-02-02 10:38:17 -05:00
parent 4a7e86e989
commit f4b50c493c
4 changed files with 30 additions and 12 deletions
+8
View File
@@ -48,7 +48,15 @@ type cacheWarmer struct {
wakeSignal chan struct{}
}
var ignoredIds = map[string]struct{}{
consts.VariousArtistsID: {},
consts.UnknownArtistID: {},
}
func (a *cacheWarmer) PreCache(artID model.ArtworkID) {
if _, shouldIgnore := ignoredIds[artID.ID]; shouldIgnore {
return
}
a.mutex.Lock()
defer a.mutex.Unlock()
a.buffer[artID] = struct{}{}