From 01e65c93eeeddff27fc2e0e4833678c5cc2829a0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 14 Dec 2013 20:17:57 -0500 Subject: updated live tv + nuget --- .../Configuration/BaseConfigurationManager.cs | 39 +++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs') diff --git a/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs b/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs index 317a288ff..3c00673ba 100644 --- a/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs +++ b/MediaBrowser.Common.Implementations/Configuration/BaseConfigurationManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Configuration; +using System.IO; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Events; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Logging; @@ -84,6 +85,8 @@ namespace MediaBrowser.Common.Implementations.Configuration CommonApplicationPaths = applicationPaths; XmlSerializer = xmlSerializer; Logger = logManager.GetLogger(GetType().Name); + + UpdateCachePath(); } /// @@ -109,6 +112,8 @@ namespace MediaBrowser.Common.Implementations.Configuration /// protected virtual void OnConfigurationUpdated() { + UpdateCachePath(); + EventHelper.QueueEventIfNotNull(ConfigurationUpdated, this, EventArgs.Empty, Logger); } @@ -124,8 +129,40 @@ namespace MediaBrowser.Common.Implementations.Configuration throw new ArgumentNullException("newConfiguration"); } + ValidateCachePath(newConfiguration); + CommonConfiguration = newConfiguration; SaveConfiguration(); } + + /// + /// Updates the items by name path. + /// + private void UpdateCachePath() + { + ((BaseApplicationPaths)CommonApplicationPaths).CachePath = string.IsNullOrEmpty(CommonConfiguration.CachePath) ? + null : + CommonConfiguration.CachePath; + } + + /// + /// Replaces the cache path. + /// + /// The new configuration. + /// + private void ValidateCachePath(BaseApplicationConfiguration newConfig) + { + var newPath = newConfig.CachePath; + + if (!string.IsNullOrWhiteSpace(newPath) + && !string.Equals(CommonConfiguration.CachePath ?? string.Empty, newPath)) + { + // Validate + if (!Directory.Exists(newPath)) + { + throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath)); + } + } + } } } -- cgit v1.2.3