revert-image cache as dictionary, concurrent not serializable

This commit is contained in:
Jeremy Wu 2020-08-10 07:17:22 +10:00
parent ffa68a5a7b
commit ca08e60308

View file

@ -14,7 +14,7 @@ namespace Flow.Launcher.Infrastructure.Image
public static class ImageLoader
{
private static readonly ImageCache ImageCache = new ImageCache();
private static BinaryStorage<ConcurrentDictionary<string, int>> _storage;
private static BinaryStorage<Dictionary<string, int>> _storage;
private static readonly ConcurrentDictionary<string, string> GuidToKey = new ConcurrentDictionary<string, string>();
private static IImageHashGenerator _hashGenerator;
private static bool EnableImageHash = true;
@ -32,7 +32,7 @@ namespace Flow.Launcher.Infrastructure.Image
public static void Initialize()
{
_storage = new BinaryStorage<ConcurrentDictionary<string, int>>("Image");
_storage = new BinaryStorage<Dictionary<string, int>>("Image");
_hashGenerator = new ImageHashGenerator();
ImageCache.Usage = LoadStorageToConcurrentDictionary();
@ -62,7 +62,7 @@ namespace Flow.Launcher.Infrastructure.Image
lock (_storage)
{
ImageCache.Cleanup();
_storage.Save(ImageCache.Usage);
_storage.Save(new Dictionary<string, int>(ImageCache.Usage));
}
}
@ -70,7 +70,7 @@ namespace Flow.Launcher.Infrastructure.Image
{
lock(_storage)
{
var loaded = _storage.TryLoad(new ConcurrentDictionary<string, int>());
var loaded = _storage.TryLoad(new Dictionary<string, int>());
return new ConcurrentDictionary<string, int>(loaded);
}