Fix #857: Clear in-memory cache as well as on disk
This commit is contained in:
@@ -283,6 +283,7 @@ func (a *App) ClearCaches() {
|
||||
}
|
||||
}
|
||||
}
|
||||
a.ImageManager.ClearInMemoryCache()
|
||||
}
|
||||
|
||||
func checkPortablePath() string {
|
||||
|
||||
@@ -66,10 +66,7 @@ func NewImageManager(ctx context.Context, s *ServerManager, baseCacheDir string)
|
||||
maxOnDiskCacheSizeBytes: defaultDiskCacheSizeBytes,
|
||||
serverFetchSema: make(chan any, maxConcurrentServerFetches),
|
||||
}
|
||||
s.OnLogout(func() {
|
||||
i.thumbnailCache.Clear()
|
||||
i.clearFullSizeCover()
|
||||
})
|
||||
s.OnLogout(i.ClearInMemoryCache)
|
||||
i.thumbnailCache.OnEvictTaskRan = func() {
|
||||
i.clearFullSizeCoverIfExpired()
|
||||
i.pruneOnDiskCache()
|
||||
@@ -195,6 +192,12 @@ func (i *ImageManager) RefreshCachedArtistImageIfExpired(artistID string, imgURL
|
||||
return err
|
||||
}
|
||||
|
||||
// ClearInMemoryCache clears images from the in-memory caches.
|
||||
func (i *ImageManager) ClearInMemoryCache() {
|
||||
i.thumbnailCache.Clear()
|
||||
i.clearFullSizeCover()
|
||||
}
|
||||
|
||||
func (i *ImageManager) ensureCoverCacheDir() string {
|
||||
// if user logged out with pending fetches in progress,
|
||||
// make sure we don't write to nil (00000000-*0) cache directory
|
||||
|
||||
Reference in New Issue
Block a user