Restructure solution into folders and fix persistence issues

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-14 14:10:24 +01:00
1 parent 37987a394a
commit 7c39cb5562
62 files changed
+219 -151

No files matched your search

@@ -0,0 +1,52 @@
using Flypaper.Core.Settings;
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.Configuration;
namespace Flypaper.Storage.Settings;
internal sealed class DbConfigurationProvider(string connectionString) : ConfigurationProvider
{
public override void Load() => Data = TryRead() ?? new Dictionary<string, string?>(StringComparer.OrdinalIgnoreCase);
public bool TryReload()
{
if (TryRead() is not { } data)
{
return false;
}
Data = data;
OnReload();
return true;
}
private Dictionary<string, string?>? TryRead()
{
var builder = new SqliteConnectionStringBuilder(connectionString) { Mode = SqliteOpenMode.ReadOnly };
try
{
using var connection = new SqliteConnection(builder.ConnectionString);
connection.Open();
using var command = connection.CreateCommand();
command.CommandText = "SELECT \"Key\", \"Value\" FROM \"Settings\"";
using var reader = command.ExecuteReader();
var data = new Dictionary<string, string?>(StringComparer.OrdinalIgnoreCase);
while (reader.Read())
{
var key = reader.GetString(0);
if (SettingKeys.All.Contains(key))
{
data[key] = reader.GetString(1);
}
}
return data;
}
catch (SqliteException)
{
return null;
}
}
}