fix(backup): use active SQLite database and validate safe restore (U01)

This commit is contained in:
2026-11-02 06:21:24 +01:00
parent 317c696e70
commit a3c1bee09e
9 changed files with 269 additions and 56 deletions
+7 -3
View File
@@ -38,11 +38,15 @@ class Program
{
try
{
File.Copy(legacyDbPath, dbPath);
using var source = new Microsoft.Data.Sqlite.SqliteConnection($"Data Source={legacyDbPath};Mode=ReadOnly");
using var target = new Microsoft.Data.Sqlite.SqliteConnection($"Data Source={dbPath}");
source.Open();
target.Open();
source.BackupDatabase(target);
}
catch
catch (Exception ex)
{
// Ignore copy errors and continue with a fresh DB.
throw new InvalidOperationException("Die vorhandene Datenbank konnte nicht ?bernommen werden. Der Start wurde abgebrochen; die urspr?ngliche Datei bleibt erhalten.", ex);
}
}