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

49 lines
1.4 KiB
C#
Raw Permalink 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;
using Flow.Launcher.Plugin;
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
{
// Expose ISaveable interface in derived class to make sure we are calling the new version of Save method
public class FlowLauncherJsonStorage<T> : JsonStorage<T>, ISavable 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);
}
}
}
}