Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into BenedekFarkas/#16888
Browse files Browse the repository at this point in the history
  • Loading branch information
BenedekFarkas committed Oct 15, 2024
2 parents e0478e8 + 8290cf7 commit 8f07a14
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/OrchardCore.Modules/OrchardCore.Email/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
Author = ManifestConstants.OrchardCoreTeam,
Website = ManifestConstants.OrchardCoreWebsite,
Version = ManifestConstants.OrchardCoreVersion,
Description = "Provides the necessary infrastructure for configuring email settings and offers a default SMTP provider.",
Description = "Provides the necessary infrastructure for configuring email settings.",
Category = "Messaging"
)]
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public async Task<DbConnectionValidatorResult> ValidateAsync(DbConnectionValidat
connection is SqliteConnection sqliteConnection &&
!File.Exists(sqliteConnection.DataSource))
{
SqliteConnection.ClearPool(sqliteConnection);
return DbConnectionValidatorResult.DocumentTableNotFound;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public static OrchardCoreBuilder AddDataAccess(this OrchardCoreBuilder builder)
var databaseFolder = SqliteHelper.GetDatabaseFolder(shellOptions, shellSettings.Name);
Directory.CreateDirectory(databaseFolder);
// Only allow creating a file DB when a tenant is in the Initializing state
var connectionString = SqliteHelper.GetConnectionString(sqliteOptions, databaseFolder, shellSettings);
storeConfiguration
Expand Down
1 change: 1 addition & 0 deletions src/OrchardCore/OrchardCore.Data.YesSql/SqliteHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static string GetConnectionString(SqliteOptions sqliteOptions, string dat
databaseName = "yessql.db";
}

// Only allow creating a file DB when a tenant is in the Initializing state.
var sqliteOpenMode = shellSettings.IsInitializing() ? SqliteOpenMode.ReadWriteCreate : SqliteOpenMode.ReadWrite;

return GetSqliteConnectionStringBuilder(sqliteOptions, databaseFolder, databaseName, sqliteOpenMode).ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@
<ProjectReference Include="..\OrchardCore.Recipes.Abstractions\OrchardCore.Recipes.Abstractions.csproj" />
<ProjectReference Include="..\OrchardCore.Setup.Abstractions\OrchardCore.Setup.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="YesSql" />
</ItemGroup>
</Project>
15 changes: 15 additions & 0 deletions src/OrchardCore/OrchardCore.Setup.Core/SetupService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Localization;
Expand All @@ -13,6 +14,7 @@
using OrchardCore.Recipes.Models;
using OrchardCore.Recipes.Services;
using OrchardCore.Setup.Events;
using YesSql;

namespace OrchardCore.Setup.Services;

Expand Down Expand Up @@ -260,6 +262,19 @@ await scope.ServiceProvider.GetService<IShellDescriptorManager>()
return executionId;
}

// When using SQLite, clearing the connection pool with ReadWriteCreate SqliteOpenMode, used when the shell was
// still initializing, to unlock the database file (and thus also allow it to be deleted).
if (shellSettings["DatabaseProvider"] == DatabaseProviderValue.Sqlite)
{
await using var shellContext = await _shellContextFactory.CreateMinimumContextAsync(shellSettings);
var store = shellContext.ServiceProvider.GetRequiredService<IStore>();
await using var connection = store.Configuration.ConnectionFactory.CreateConnection();
if (connection is SqliteConnection sqliteConnection)
{
SqliteConnection.ClearPool(sqliteConnection);
}
}

// Update the shell state.
await _shellHost.UpdateShellSettingsAsync(shellSettings.AsRunning());

Expand Down

0 comments on commit 8f07a14

Please sign in to comment.