diff options
Diffstat (limited to 'MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs index 94438e3e0..5ae3af5e2 100644 --- a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -60,6 +60,7 @@ namespace MediaBrowser.Server.Implementations.Configuration protected override void OnConfigurationUpdated() { UpdateItemsByNamePath(); + UpdateTranscodingTempPath(); base.OnConfigurationUpdated(); } @@ -75,6 +76,16 @@ namespace MediaBrowser.Server.Implementations.Configuration } /// <summary> + /// Updates the transcoding temporary path. + /// </summary> + private void UpdateTranscodingTempPath() + { + ((ServerApplicationPaths)ApplicationPaths).TranscodingTempPath = string.IsNullOrEmpty(Configuration.TranscodingTempPath) ? + null : + Configuration.TranscodingTempPath; + } + + /// <summary> /// Replaces the configuration. /// </summary> /// <param name="newConfiguration">The new configuration.</param> @@ -84,6 +95,7 @@ namespace MediaBrowser.Server.Implementations.Configuration var newConfig = (ServerConfiguration) newConfiguration; ValidateItemByNamePath(newConfig); + ValidateTranscodingTempPath(newConfig); base.ReplaceConfiguration(newConfiguration); } @@ -107,5 +119,25 @@ namespace MediaBrowser.Server.Implementations.Configuration } } } + + /// <summary> + /// Validates the transcoding temporary path. + /// </summary> + /// <param name="newConfig">The new configuration.</param> + /// <exception cref="DirectoryNotFoundException"></exception> + private void ValidateTranscodingTempPath(ServerConfiguration newConfig) + { + var newPath = newConfig.TranscodingTempPath; + + if (!string.IsNullOrWhiteSpace(newPath) + && !string.Equals(Configuration.TranscodingTempPath ?? string.Empty, newPath)) + { + // Validate + if (!Directory.Exists(newPath)) + { + throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath)); + } + } + } } } |
