Cleanup: Veraltetes Setting 'ScanIntervalHours' beim Start aus DB entfernen
This commit is contained in:
1 parent
3d0049a4f1
commit
a6a0223f44
1 file changed
+22
@@ -77,12 +77,34 @@ public class ServerSettingsService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Entfernt veraltete Settings aus der DB die nicht mehr in Definitions existieren.
|
||||
/// </summary>
|
||||
private void CleanupObsoleteSettings()
|
||||
{
|
||||
var obsoleteKeys = new[] { "ScanIntervalHours" };
|
||||
using var conn = new SqliteConnection($"Data Source={_dbPath}");
|
||||
conn.Open();
|
||||
foreach (var key in obsoleteKeys)
|
||||
{
|
||||
using var cmd = conn.CreateCommand();
|
||||
cmd.CommandText = "DELETE FROM server_settings WHERE key = @key";
|
||||
cmd.Parameters.AddWithValue("@key", key);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
lock (_lock)
|
||||
{
|
||||
foreach (var key in obsoleteKeys) _cache.Remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Migriert bestehende Werte aus appsettings.Production.json in die DB (einmalig).
|
||||
/// Nur Settings die noch NICHT in der DB sind werden übernommen.
|
||||
/// </summary>
|
||||
public void MigrateFromAppSettings(string contentRootPath)
|
||||
{
|
||||
CleanupObsoleteSettings();
|
||||
var prodPath = Path.Combine(contentRootPath, "appsettings.Production.json");
|
||||
if (!File.Exists(prodPath)) return;
|
||||
|
||||
|
||||
Reference in new issue
Block a user