Fixed removing temp. database file when importing JSON

This commit is contained in:
tsommer committed 2023-02-11 23:03:14 +01:00
1 parent 18fd1faedd
commit 96823aa948
3 files changed
+46 -32

No files matched your search

+22 -21
View File
@@ -60,30 +60,31 @@ internal static class Program
}
});
// Tear down the setup:
using var setupMaintenance = Setup.Maintenance;
// Get the host out of the DI system:
var host = builder.Build();
// Create a service scope:
using (var scope = host.Services.CreateScope())
using (var host = builder.Build())
{
// Get a service provider:
SERVICE_PROVIDER = scope.ServiceProvider;
// Set the service provider to the processor:
ProcessorMeta.ServiceProvider = SERVICE_PROVIDER;
// Apply database migrations:
using (var database = SERVICE_PROVIDER.GetRequiredService<DataContext>())
Setup.PerformDataMigration(database).Wait();
// Start the app:
do
// Create a service scope:
using (var scope = host.Services.CreateScope())
{
Application.Run(new Main());
} while (Program.RestartMainApp);
// Get a service provider:
SERVICE_PROVIDER = scope.ServiceProvider;
// Set the service provider to the processor:
ProcessorMeta.ServiceProvider = SERVICE_PROVIDER;
// Apply database migrations:
using (var database = SERVICE_PROVIDER.GetRequiredService<DataContext>())
Setup.PerformDataMigration(database).Wait();
// Start the app:
do
{
Application.Run(new Main());
} while (Program.RestartMainApp);
}
}
// Tear down the setup:
AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) => Setup.SETUP_MAINTENANCE.Dispose();
}
}