Skip to content

Commit

Permalink
Remove double database connection validation in setup (#12826)
Browse files Browse the repository at this point in the history
  • Loading branch information
TFleury authored Dec 9, 2022
1 parent 110afb2 commit a69c190
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,4 @@
<ProjectReference Include="..\OrchardCore.Recipes.Abstractions\OrchardCore.Recipes.Abstractions.csproj" />
<ProjectReference Include="..\OrchardCore.Setup.Abstractions\OrchardCore.Setup.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="YesSql.Abstractions" />
</ItemGroup>
</Project>
26 changes: 6 additions & 20 deletions src/OrchardCore/OrchardCore.Setup.Core/SetupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OrchardCore.Abstractions.Setup;
using OrchardCore.Data;
using OrchardCore.Data.YesSql;
using OrchardCore.Environment.Shell;
using OrchardCore.Environment.Shell.Builders;
using OrchardCore.Environment.Shell.Descriptor;
Expand All @@ -20,7 +18,6 @@
using OrchardCore.Recipes.Models;
using OrchardCore.Recipes.Services;
using OrchardCore.Setup.Events;
using YesSql;

namespace OrchardCore.Setup.Services
{
Expand Down Expand Up @@ -202,32 +199,21 @@ private async Task<string> SetupInternalAsync(SetupContext context)
{
await shellContext.CreateScope().UsingServiceScopeAsync(async scope =>
{
IStore store;
try
{
store = scope.ServiceProvider.GetRequiredService<IStore>();
// Create the "minimum shell descriptor"
await scope
.ServiceProvider
.GetService<IShellDescriptorManager>()
.UpdateShellDescriptorAsync(0,
shellContext.Blueprint.Descriptor.Features);
}
catch (Exception e)
{
// Tables already exist or database was not found
// The issue is that the user creation needs the tables to be present,
// if the user information is not valid, the next POST will try to recreate the
// tables. The tables should be rolled back if one of the steps is invalid,
// unless the recipe is executing?
_logger.LogError(e, "An error occurred while initializing the datastore.");
context.Errors.Add(String.Empty, S["An error occurred while initializing the datastore: {0}", e.Message]);
return;
}
// Create the "minimum shell descriptor"
await scope
.ServiceProvider
.GetService<IShellDescriptorManager>()
.UpdateShellDescriptorAsync(0,
shellContext.Blueprint.Descriptor.Features);
});

if (context.Errors.Any())
Expand Down

0 comments on commit a69c190

Please sign in to comment.