Use a custom artist image cache key.

Invalidate when `Agents` config changes. This should solve https://github.com/navidrome/navidrome/issues/1601#issuecomment-1241702797
This commit is contained in:
Deluan
2023-01-13 17:23:28 -05:00
committed by Deluan Quintão
parent 94c6d47181
commit ab7668f562
+13
View File
@@ -2,6 +2,7 @@ package artwork
import (
"context"
"crypto/md5"
"fmt"
"io"
"io/fs"
@@ -12,6 +13,7 @@ import (
"time"
"github.com/Masterminds/squirrel"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/core"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
@@ -57,6 +59,17 @@ func newArtistReader(ctx context.Context, artwork *artwork, artID model.ArtworkI
return a, nil
}
func (a *artistReader) Key() string {
agentsHash := md5.Sum([]byte(conf.Server.Agents + conf.Server.Spotify.ID))
return fmt.Sprintf(
"%s.%d.%d.%x",
a.artID,
a.lastUpdate.UnixMilli(),
a.size,
agentsHash,
)
}
func (a *artistReader) LastUpdated() time.Time {
return a.lastUpdate
}