Fix #857: Clear in-memory cache as well as on disk

This commit is contained in:
Drew Weymouth
2026-02-19 08:27:32 -08:00
parent 9dd606ce73
commit 6b382c6293
2 changed files with 23 additions and 19 deletions
+1
View File
@@ -283,6 +283,7 @@ func (a *App) ClearCaches() {
} }
} }
} }
a.ImageManager.ClearInMemoryCache()
} }
func checkPortablePath() string { func checkPortablePath() string {
+7 -4
View File
@@ -66,10 +66,7 @@ func NewImageManager(ctx context.Context, s *ServerManager, baseCacheDir string)
maxOnDiskCacheSizeBytes: defaultDiskCacheSizeBytes, maxOnDiskCacheSizeBytes: defaultDiskCacheSizeBytes,
serverFetchSema: make(chan any, maxConcurrentServerFetches), serverFetchSema: make(chan any, maxConcurrentServerFetches),
} }
s.OnLogout(func() { s.OnLogout(i.ClearInMemoryCache)
i.thumbnailCache.Clear()
i.clearFullSizeCover()
})
i.thumbnailCache.OnEvictTaskRan = func() { i.thumbnailCache.OnEvictTaskRan = func() {
i.clearFullSizeCoverIfExpired() i.clearFullSizeCoverIfExpired()
i.pruneOnDiskCache() i.pruneOnDiskCache()
@@ -195,6 +192,12 @@ func (i *ImageManager) RefreshCachedArtistImageIfExpired(artistID string, imgURL
return err return err
} }
// ClearInMemoryCache clears images from the in-memory caches.
func (i *ImageManager) ClearInMemoryCache() {
i.thumbnailCache.Clear()
i.clearFullSizeCover()
}
func (i *ImageManager) ensureCoverCacheDir() string { func (i *ImageManager) ensureCoverCacheDir() string {
// if user logged out with pending fetches in progress, // if user logged out with pending fetches in progress,
// make sure we don't write to nil (00000000-*0) cache directory // make sure we don't write to nil (00000000-*0) cache directory