aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs')
-rw-r--r--Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs61
1 files changed, 23 insertions, 38 deletions
diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
index c7f92b80b..3d8d15d19 100644
--- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
+++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
using Emby.Server.Implementations.AppBase;
using MediaBrowser.Common.Configuration;
@@ -14,11 +15,10 @@ using Microsoft.Extensions.Logging;
namespace Emby.Server.Implementations.Configuration
{
/// <summary>
- /// Class ServerConfigurationManager
+ /// Class ServerConfigurationManager.
/// </summary>
public class ServerConfigurationManager : BaseConfigurationManager, IServerConfigurationManager
{
-
/// <summary>
/// Initializes a new instance of the <see cref="ServerConfigurationManager" /> class.
/// </summary>
@@ -32,6 +32,9 @@ namespace Emby.Server.Implementations.Configuration
UpdateMetadataPath();
}
+ /// <summary>
+ /// Configuration updating event.
+ /// </summary>
public event EventHandler<GenericEventArgs<ServerConfiguration>> ConfigurationUpdating;
/// <summary>
@@ -62,13 +65,6 @@ namespace Emby.Server.Implementations.Configuration
base.OnConfigurationUpdated();
}
- public override void AddParts(IEnumerable<IConfigurationFactory> factories)
- {
- base.AddParts(factories);
-
- UpdateTranscodePath();
- }
-
/// <summary>
/// Updates the metadata path.
/// </summary>
@@ -85,28 +81,6 @@ namespace Emby.Server.Implementations.Configuration
}
/// <summary>
- /// Updates the transcoding temporary path.
- /// </summary>
- private void UpdateTranscodePath()
- {
- var encodingConfig = this.GetConfiguration<EncodingOptions>("encoding");
-
- ((ServerApplicationPaths)ApplicationPaths).TranscodingTempPath = string.IsNullOrEmpty(encodingConfig.TranscodingTempPath) ?
- null :
- Path.Combine(encodingConfig.TranscodingTempPath, "transcodes");
- }
-
- protected override void OnNamedConfigurationUpdated(string key, object configuration)
- {
- base.OnNamedConfigurationUpdated(key, configuration);
-
- if (string.Equals(key, "encoding", StringComparison.OrdinalIgnoreCase))
- {
- UpdateTranscodePath();
- }
- }
-
- /// <summary>
/// Replaces the configuration.
/// </summary>
/// <param name="newConfiguration">The new configuration.</param>
@@ -123,12 +97,11 @@ namespace Emby.Server.Implementations.Configuration
base.ReplaceConfiguration(newConfiguration);
}
-
/// <summary>
/// Validates the SSL certificate.
/// </summary>
/// <param name="newConfig">The new configuration.</param>
- /// <exception cref="DirectoryNotFoundException"></exception>
+ /// <exception cref="FileNotFoundException">The certificate path doesn't exist.</exception>
private void ValidateSslCertificate(BaseApplicationConfiguration newConfig)
{
var serverConfig = (ServerConfiguration)newConfig;
@@ -136,12 +109,16 @@ namespace Emby.Server.Implementations.Configuration
var newPath = serverConfig.CertificatePath;
if (!string.IsNullOrWhiteSpace(newPath)
- && !string.Equals(Configuration.CertificatePath ?? string.Empty, newPath))
+ && !string.Equals(Configuration.CertificatePath, newPath, StringComparison.Ordinal))
{
// Validate
if (!File.Exists(newPath))
{
- throw new FileNotFoundException(string.Format("Certificate file '{0}' does not exist.", newPath));
+ throw new FileNotFoundException(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "Certificate file '{0}' does not exist.",
+ newPath));
}
}
}
@@ -150,24 +127,32 @@ namespace Emby.Server.Implementations.Configuration
/// Validates the metadata path.
/// </summary>
/// <param name="newConfig">The new configuration.</param>
- /// <exception cref="DirectoryNotFoundException"></exception>
+ /// <exception cref="DirectoryNotFoundException">The new config path doesn't exist.</exception>
private void ValidateMetadataPath(ServerConfiguration newConfig)
{
var newPath = newConfig.MetadataPath;
if (!string.IsNullOrWhiteSpace(newPath)
- && !string.Equals(Configuration.MetadataPath ?? string.Empty, newPath))
+ && !string.Equals(Configuration.MetadataPath, newPath, StringComparison.Ordinal))
{
// Validate
if (!Directory.Exists(newPath))
{
- throw new FileNotFoundException(string.Format("{0} does not exist.", newPath));
+ throw new DirectoryNotFoundException(
+ string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} does not exist.",
+ newPath));
}
EnsureWriteAccess(newPath);
}
}
+ /// <summary>
+ /// Sets all configuration values to their optimal values.
+ /// </summary>
+ /// <returns>If the configuration changed.</returns>
public bool SetOptimalValues()
{
var config = Configuration;