diff options
| author | Patrick Barron <barronpm@gmail.com> | 2021-06-18 18:47:44 -0400 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2021-06-18 18:56:10 -0400 |
| commit | be88efce3cbbd357142a75f109258d6c7be398b4 (patch) | |
| tree | df8a0bf9d5e108d45a473edd8121a9af91ca6a0d /Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs | |
| parent | 336ba2879f325a4efd52bc7737ce94f40369bfeb (diff) | |
| parent | c791c3a215b33bd4ca534c9f383c9fd7d23b59af (diff) | |
Merge branch 'master' into authenticationdb-efcore
# Conflicts:
# Emby.Server.Implementations/Devices/DeviceManager.cs
# Emby.Server.Implementations/HttpServer/Security/SessionContext.cs
# Emby.Server.Implementations/Security/AuthenticationRepository.cs
# Emby.Server.Implementations/Session/SessionManager.cs
# Jellyfin.Server.Implementations/Security/AuthorizationContext.cs
# MediaBrowser.Controller/Library/IUserManager.cs
# MediaBrowser.Controller/Net/ISessionContext.cs
Diffstat (limited to 'Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 4f72c8ce1..d38535634 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -23,6 +25,11 @@ namespace Emby.Server.Implementations.AppBase private readonly ConcurrentDictionary<string, object> _configurations = new ConcurrentDictionary<string, object>(); + /// <summary> + /// The _configuration sync lock. + /// </summary> + private readonly object _configurationSyncLock = new object(); + private ConfigurationStore[] _configurationStores = Array.Empty<ConfigurationStore>(); private IConfigurationFactory[] _configurationFactories = Array.Empty<IConfigurationFactory>(); @@ -32,11 +39,6 @@ namespace Emby.Server.Implementations.AppBase private bool _configurationLoaded; /// <summary> - /// The _configuration sync lock. - /// </summary> - private readonly object _configurationSyncLock = new object(); - - /// <summary> /// The _configuration. /// </summary> private BaseApplicationConfiguration _configuration; @@ -297,25 +299,29 @@ namespace Emby.Server.Implementations.AppBase /// <inheritdoc /> public object GetConfiguration(string key) { - return _configurations.GetOrAdd(key, k => - { - var file = GetConfigurationFile(key); + return _configurations.GetOrAdd( + key, + (k, configurationManager) => + { + var file = configurationManager.GetConfigurationFile(k); - var configurationInfo = _configurationStores - .FirstOrDefault(i => string.Equals(i.Key, key, StringComparison.OrdinalIgnoreCase)); + var configurationInfo = Array.Find( + configurationManager._configurationStores, + i => string.Equals(i.Key, k, StringComparison.OrdinalIgnoreCase)); - if (configurationInfo == null) - { - throw new ResourceNotFoundException("Configuration with key " + key + " not found."); - } + if (configurationInfo == null) + { + throw new ResourceNotFoundException("Configuration with key " + k + " not found."); + } - var configurationType = configurationInfo.ConfigurationType; + var configurationType = configurationInfo.ConfigurationType; - lock (_configurationSyncLock) - { - return LoadConfiguration(file, configurationType); - } - }); + lock (configurationManager._configurationSyncLock) + { + return configurationManager.LoadConfiguration(file, configurationType); + } + }, + this); } private object LoadConfiguration(string path, Type configurationType) |
