Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Reload Stream Config Provider #14499

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/OrchardCore/OrchardCore/Shell/ShellSettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public async Task<IEnumerable<ShellSettings>> LoadSettingsAsync()
try
{
await EnsureConfigurationAsync();
await ReloadTenantsSettingsAsync();

var tenants = _tenantsSettingsRoot.GetChildren().Select(section => section.Key);
var allTenants = _configuredTenants.Concat(tenants).Distinct().ToArray();
Expand Down Expand Up @@ -94,8 +95,7 @@ public async Task<IEnumerable<string>> LoadSettingsNamesAsync()
try
{
await EnsureConfigurationAsync();

_tenantsSettingsRoot.Reload();
await ReloadTenantsSettingsAsync();

var tenants = _tenantsSettingsRoot.GetChildren().Select(section => section.Key);
return _configuredTenants.Concat(tenants).Distinct().ToArray();
Expand All @@ -112,8 +112,7 @@ public async Task<ShellSettings> LoadSettingsAsync(string tenant)
try
{
await EnsureConfigurationAsync();

_tenantsSettingsRoot.Reload();
await ReloadTenantsSettingsAsync();

var tenantSettingsBuilder = new ConfigurationBuilder()
.AddConfiguration(_configuration)
Expand Down Expand Up @@ -277,10 +276,6 @@ private async Task EnsureConfigurationAsync()
.Distinct()
.ToArray();

_tenantsSettingsRoot = (await new ConfigurationBuilder()
.AddSourcesAsync(_tenantsSettingsSources))
.Build();

_tenantConfigFactoryAsync = async (tenant, configure) =>
{
await _tenantConfigSemaphore.WaitAsync();
Expand All @@ -304,6 +299,15 @@ private async Task EnsureConfigurationAsync()
_configuration = configuration;
}

private async Task ReloadTenantsSettingsAsync()
{
using var disposable = _tenantsSettingsRoot as IDisposable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did you learn that from! This is C# magic

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember ;) I know that var disposable will be disposed without failing if it is null.


_tenantsSettingsRoot = (await new ConfigurationBuilder()
.AddSourcesAsync(_tenantsSettingsSources))
.Build();
}

public void Dispose()
{
if (_disposed)
Expand Down