From 7f57ef068932b054eb390bba850f41af0a5437c4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 11 Jan 2014 13:58:50 -0500 Subject: support configurable transcoding temporary path --- .../Configuration/ServerConfigurationManager.cs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs') 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(); } @@ -74,6 +75,16 @@ namespace MediaBrowser.Server.Implementations.Configuration Configuration.ItemsByNamePath; } + /// + /// Updates the transcoding temporary path. + /// + private void UpdateTranscodingTempPath() + { + ((ServerApplicationPaths)ApplicationPaths).TranscodingTempPath = string.IsNullOrEmpty(Configuration.TranscodingTempPath) ? + null : + Configuration.TranscodingTempPath; + } + /// /// Replaces the configuration. /// @@ -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 } } } + + /// + /// Validates the transcoding temporary path. + /// + /// The new configuration. + /// + 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)); + } + } + } } } -- cgit v1.2.3