make metadata path configurable

This commit is contained in:
Luke Pulverenti
2014-03-25 17:13:55 -04:00
parent 7c94203d05
commit 31e8288393
33 changed files with 204 additions and 339 deletions

View File

@@ -26,6 +26,7 @@ namespace MediaBrowser.Server.Implementations.Configuration
{
UpdateItemsByNamePath();
UpdateTranscodingTempPath();
UpdateMetadataPath();
}
/// <summary>
@@ -76,6 +77,16 @@ namespace MediaBrowser.Server.Implementations.Configuration
Configuration.ItemsByNamePath;
}
/// <summary>
/// Updates the metadata path.
/// </summary>
private void UpdateMetadataPath()
{
((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath = string.IsNullOrEmpty(Configuration.MetadataPath) ?
null :
Configuration.MetadataPath;
}
/// <summary>
/// Updates the transcoding temporary path.
/// </summary>
@@ -98,6 +109,7 @@ namespace MediaBrowser.Server.Implementations.Configuration
ValidateItemByNamePath(newConfig);
ValidateTranscodingTempPath(newConfig);
ValidatePathSubstitutions(newConfig);
ValidateMetadataPath(newConfig);
base.ReplaceConfiguration(newConfiguration);
}
@@ -166,5 +178,25 @@ namespace MediaBrowser.Server.Implementations.Configuration
}
}
}
/// <summary>
/// Validates the metadata path.
/// </summary>
/// <param name="newConfig">The new configuration.</param>
/// <exception cref="System.IO.DirectoryNotFoundException"></exception>
private void ValidateMetadataPath(ServerConfiguration newConfig)
{
var newPath = newConfig.MetadataPath;
if (!string.IsNullOrWhiteSpace(newPath)
&& !string.Equals(Configuration.MetadataPath ?? string.Empty, newPath))
{
// Validate
if (!Directory.Exists(newPath))
{
throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath));
}
}
}
}
}