support configurable transcoding temporary path

This commit is contained in:
Luke Pulverenti
2014-01-11 13:58:50 -05:00
parent ef8b02d285
commit 7f57ef0689
9 changed files with 51 additions and 17 deletions

View File

@@ -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;
}
/// <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>
@@ -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));
}
}
}
}
}