Flow.Launcher/Flow.Launcher.Infrastructure/Storage/PluginBinaryStorage.cs

47 lines
1.3 KiB
C#
Raw Permalink Normal View History

2025-04-01 06:16:32 +00:00
using System.IO;
2025-04-04 08:45:58 +00:00
using System.Threading.Tasks;
2025-04-13 09:11:36 +00:00
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Plugin;
2025-04-04 08:45:58 +00:00
using Flow.Launcher.Plugin.SharedCommands;
2025-04-01 06:16:32 +00:00
namespace Flow.Launcher.Infrastructure.Storage
{
// Expose ISaveable interface in derived class to make sure we are calling the new version of Save method
public class PluginBinaryStorage<T> : BinaryStorage<T>, ISavable where T : new()
2025-04-01 06:16:32 +00:00
{
2025-04-04 08:45:58 +00:00
private static readonly string ClassName = "PluginBinaryStorage";
2025-04-01 06:16:32 +00:00
public PluginBinaryStorage(string cacheName, string cacheDirectory)
{
DirectoryPath = cacheDirectory;
2025-04-04 08:45:58 +00:00
FilesFolders.ValidateDirectory(DirectoryPath);
2025-04-01 06:16:32 +00:00
FilePath = Path.Combine(DirectoryPath, $"{cacheName}{FileSuffix}");
}
2025-04-04 08:45:58 +00:00
public new void Save()
{
try
{
base.Save();
}
catch (System.Exception e)
{
2025-04-13 09:11:36 +00:00
Log.Exception(ClassName, $"Failed to save plugin caches to path: {FilePath}", e);
2025-04-04 08:45:58 +00:00
}
}
public new async Task SaveAsync()
{
try
{
await base.SaveAsync();
}
catch (System.Exception e)
{
2025-04-13 09:11:36 +00:00
Log.Exception(ClassName, $"Failed to save plugin caches to path: {FilePath}", e);
2025-04-04 08:45:58 +00:00
}
}
2025-04-01 06:16:32 +00:00
}
}