diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-04-23 15:17:21 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-04-23 15:17:21 -0400 |
| commit | 4390e2f7108f24f89a1bf7ef9f6f7c9c57b4f221 (patch) | |
| tree | f0c18dd698667e186bffc6ab72509982d3122f3b /MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs | |
| parent | 0e7ad811acfa6a12555dfb205cd259584565b0e9 (diff) | |
#35 - Make IBN path configurable
Diffstat (limited to 'MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs index cb4c5a6cd..bdc4fcf45 100644 --- a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Configuration; +using System.IO; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Implementations.Configuration; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; @@ -23,6 +24,7 @@ namespace MediaBrowser.Server.Implementations.Configuration public ServerConfigurationManager(IApplicationPaths applicationPaths, ILogManager logManager, IXmlSerializer xmlSerializer) : base(applicationPaths, logManager, xmlSerializer) { + UpdateItemsByNamePath(); } /// <summary> @@ -51,5 +53,47 @@ namespace MediaBrowser.Server.Implementations.Configuration { get { return (ServerConfiguration)CommonConfiguration; } } + + /// <summary> + /// Called when [configuration updated]. + /// </summary> + protected override void OnConfigurationUpdated() + { + UpdateItemsByNamePath(); + + base.OnConfigurationUpdated(); + } + + /// <summary> + /// Updates the items by name path. + /// </summary> + private void UpdateItemsByNamePath() + { + if (!string.IsNullOrEmpty(Configuration.ItemsByNamePath)) + { + ApplicationPaths.ItemsByNamePath = Configuration.ItemsByNamePath; + } + } + + /// <summary> + /// Replaces the configuration. + /// </summary> + /// <param name="newConfiguration">The new configuration.</param> + /// <exception cref="System.IO.DirectoryNotFoundException"></exception> + public override void ReplaceConfiguration(BaseApplicationConfiguration newConfiguration) + { + var newConfig = (ServerConfiguration) newConfiguration; + + if (!string.Equals(Configuration.ItemsByNamePath, newConfig.ItemsByNamePath)) + { + // Validate + if (!Directory.Exists(newConfig.ItemsByNamePath)) + { + throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newConfig.ItemsByNamePath)); + } + } + + base.ReplaceConfiguration(newConfiguration); + } } } |
