diff options
| author | crobibero <cody@robibe.ro> | 2020-08-04 20:29:06 -0600 |
|---|---|---|
| committer | crobibero <cody@robibe.ro> | 2020-08-04 20:29:06 -0600 |
| commit | e65ecb5687af42270974dec77b38137407611bec (patch) | |
| tree | d17e4e672d69134175eedc556a7acc4117314a71 /MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationStore.cs | |
| parent | ff4489575b0b29638285a0cf255289134900009f (diff) | |
| parent | c12a49361c64f650706baba7edee4f616da84768 (diff) | |
Merge remote-tracking branch 'upstream/master' into api-merge-again
Diffstat (limited to 'MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationStore.cs')
| -rw-r--r-- | MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationStore.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationStore.cs b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationStore.cs new file mode 100644 index 000000000..2f158157e --- /dev/null +++ b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationStore.cs @@ -0,0 +1,38 @@ +#pragma warning disable CS1591 + +using System; +using System.Globalization; +using System.IO; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Model.Configuration; + +namespace MediaBrowser.MediaEncoding.Configuration +{ + public class EncodingConfigurationStore : ConfigurationStore, IValidatingConfiguration + { + public EncodingConfigurationStore() + { + ConfigurationType = typeof(EncodingOptions); + Key = "encoding"; + } + + public void Validate(object oldConfig, object newConfig) + { + var newPath = ((EncodingOptions)newConfig).TranscodingTempPath; + + if (!string.IsNullOrWhiteSpace(newPath) + && !string.Equals(((EncodingOptions)oldConfig).TranscodingTempPath, newPath, StringComparison.Ordinal)) + { + // Validate + if (!Directory.Exists(newPath)) + { + throw new DirectoryNotFoundException( + string.Format( + CultureInfo.InvariantCulture, + "{0} does not exist.", + newPath)); + } + } + } + } +} |
