EncodingConfigurationStore.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Globalization;
  4. using System.IO;
  5. using MediaBrowser.Common.Configuration;
  6. using MediaBrowser.Model.Configuration;
  7. namespace MediaBrowser.MediaEncoding.Configuration
  8. {
  9. public class EncodingConfigurationStore : ConfigurationStore, IValidatingConfiguration
  10. {
  11. public EncodingConfigurationStore()
  12. {
  13. ConfigurationType = typeof(EncodingOptions);
  14. Key = "encoding";
  15. }
  16. public void Validate(object oldConfig, object newConfig)
  17. {
  18. var newPath = ((EncodingOptions)newConfig).TranscodingTempPath;
  19. if (!string.IsNullOrWhiteSpace(newPath)
  20. && !string.Equals(((EncodingOptions)oldConfig).TranscodingTempPath, newPath, StringComparison.Ordinal))
  21. {
  22. // Validate
  23. if (!Directory.Exists(newPath))
  24. {
  25. throw new DirectoryNotFoundException(
  26. string.Format(
  27. CultureInfo.InvariantCulture,
  28. "{0} does not exist.",
  29. newPath));
  30. }
  31. }
  32. }
  33. }
  34. }