aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2019-12-10 23:00:59 +0100
committerBond_009 <bond.009@outlook.com>2019-12-10 23:00:59 +0100
commit0bf8bfbb0cfd67b387a574148022f3c554ff5173 (patch)
tree34f12fcce7b688fc50d377f90dbccc343e03b310 /Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
parentc6d48f51f608601775d98fc7866eefc367bfd63b (diff)
parent67922dff50967c02e8c0c10f43884fd4e788b012 (diff)
Merge branch 'master' into mediaencoding
Diffstat (limited to 'Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs')
-rw-r--r--Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs26
1 files changed, 22 insertions, 4 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
index 67bb25b07..080cfbbd1 100644
--- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
+++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs
@@ -84,6 +84,7 @@ namespace Emby.Server.Implementations.AppBase
/// </summary>
/// <value>The logger.</value>
protected ILogger Logger { get; private set; }
+
/// <summary>
/// Gets the XML serializer.
/// </summary>
@@ -97,7 +98,7 @@ namespace Emby.Server.Implementations.AppBase
public IApplicationPaths CommonApplicationPaths { get; private set; }
/// <summary>
- /// Gets the system configuration.
+ /// Gets or sets the system configuration.
/// </summary>
/// <value>The configuration.</value>
public BaseApplicationConfiguration CommonConfiguration
@@ -123,6 +124,7 @@ namespace Emby.Server.Implementations.AppBase
return _configuration;
}
}
+
protected set
{
_configuration = value;
@@ -131,6 +133,10 @@ namespace Emby.Server.Implementations.AppBase
}
}
+ /// <summary>
+ /// Adds parts.
+ /// </summary>
+ /// <param name="factories">The configuration factories.</param>
public virtual void AddParts(IEnumerable<IConfigurationFactory> factories)
{
_configurationFactories = factories.ToArray();
@@ -215,7 +221,7 @@ namespace Emby.Server.Implementations.AppBase
cachePath = CommonConfiguration.CachePath;
}
- Logger.LogInformation("Setting cache path to " + cachePath);
+ Logger.LogInformation("Setting cache path: {Path}", cachePath);
((BaseApplicationPaths)CommonApplicationPaths).CachePath = cachePath;
}
@@ -223,7 +229,7 @@ namespace Emby.Server.Implementations.AppBase
/// Replaces the cache path.
/// </summary>
/// <param name="newConfig">The new configuration.</param>
- /// <exception cref="DirectoryNotFoundException"></exception>
+ /// <exception cref="DirectoryNotFoundException">The new cache path doesn't exist.</exception>
private void ValidateCachePath(BaseApplicationConfiguration newConfig)
{
var newPath = newConfig.CachePath;
@@ -234,7 +240,7 @@ namespace Emby.Server.Implementations.AppBase
// Validate
if (!Directory.Exists(newPath))
{
- throw new FileNotFoundException(
+ throw new DirectoryNotFoundException(
string.Format(
CultureInfo.InvariantCulture,
"{0} does not exist.",
@@ -245,6 +251,10 @@ namespace Emby.Server.Implementations.AppBase
}
}
+ /// <summary>
+ /// Ensures that we have write access to the path.
+ /// </summary>
+ /// <param name="path">The path.</param>
protected void EnsureWriteAccess(string path)
{
var file = Path.Combine(path, Guid.NewGuid().ToString());
@@ -257,6 +267,7 @@ namespace Emby.Server.Implementations.AppBase
return Path.Combine(CommonApplicationPaths.ConfigurationDirectoryPath, key.ToLowerInvariant() + ".xml");
}
+ /// <inheritdoc />
public object GetConfiguration(string key)
{
return _configurations.GetOrAdd(key, k =>
@@ -303,6 +314,7 @@ namespace Emby.Server.Implementations.AppBase
}
}
+ /// <inheritdoc />
public void SaveConfiguration(string key, object configuration)
{
var configurationStore = GetConfigurationStore(key);
@@ -339,6 +351,11 @@ namespace Emby.Server.Implementations.AppBase
OnNamedConfigurationUpdated(key, configuration);
}
+ /// <summary>
+ /// Event handler for when a named configuration has been updated.
+ /// </summary>
+ /// <param name="key">The key of the configuration.</param>
+ /// <param name="configuration">The old configuration.</param>
protected virtual void OnNamedConfigurationUpdated(string key, object configuration)
{
NamedConfigurationUpdated?.Invoke(this, new ConfigurationUpdateEventArgs
@@ -348,6 +365,7 @@ namespace Emby.Server.Implementations.AppBase
});
}
+ /// <inheritdoc />
public Type GetConfigurationType(string key)
{
return GetConfigurationStore(key)