Flow.Launcher/Flow.Launcher.Infrastructure/Storage/FlowLauncherJsonStorage.cs

47 lines
1.3 KiB
C#
Raw Normal View History

2023-04-25 12:04:08 +00:00
using System.IO;
using System.Threading.Tasks;
2025-04-13 09:11:36 +00:00
using Flow.Launcher.Infrastructure.Logger;
2020-04-21 09:12:17 +00:00
using Flow.Launcher.Infrastructure.UserSettings;
2025-04-04 03:46:07 +00:00
using Flow.Launcher.Plugin.SharedCommands;
2020-04-21 09:12:17 +00:00
namespace Flow.Launcher.Infrastructure.Storage
{
2021-05-11 19:10:03 +00:00
public class FlowLauncherJsonStorage<T> : JsonStorage<T> where T : new()
{
private static readonly string ClassName = "FlowLauncherJsonStorage";
2020-04-21 12:16:10 +00:00
public FlowLauncherJsonStorage()
{
2025-04-11 14:13:58 +00:00
DirectoryPath = Path.Combine(DataLocation.DataDirectory(), DirectoryName);
FilesFolders.ValidateDirectory(DirectoryPath);
var filename = typeof(T).Name;
2025-04-11 14:13:58 +00:00
FilePath = Path.Combine(DirectoryPath, $"{filename}{FileSuffix}");
}
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 FL settings to path: {FilePath}", e);
}
}
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 FL settings to path: {FilePath}", e);
}
}
}
}