fix(backup): use active SQLite database and validate safe restore (U01)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user