aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs4
-rw-r--r--Emby.Server.Implementations/ServerApplicationPaths.cs12
-rw-r--r--MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs14
-rw-r--r--MediaBrowser.Controller/IServerApplicationPaths.cs7
4 files changed, 26 insertions, 11 deletions
diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
index 30b654886..9c9b0c79c 100644
--- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
+++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
@@ -67,6 +67,9 @@ namespace Emby.Server.Implementations.Configuration
/// <summary>
/// Updates the metadata path.
/// </summary>
+ /// <exception cref="UnauthorizedAccessException">If the directory does not exist, and the caller does not have the required permission to create it.</exception>
+ /// <exception cref="NotSupportedException">If there is a custom path transcoding path specified, but it is invalid.</exception>
+ /// <exception cref="IOException">If the directory does not exist, and it also could not be created.</exception>
private void UpdateMetadataPath()
{
if (string.IsNullOrWhiteSpace(Configuration.MetadataPath))
@@ -77,6 +80,7 @@ namespace Emby.Server.Implementations.Configuration
{
((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath = Configuration.MetadataPath;
}
+ Directory.CreateDirectory(ApplicationPaths.InternalMetadataPath);
}
/// <summary>
diff --git a/Emby.Server.Implementations/ServerApplicationPaths.cs b/Emby.Server.Implementations/ServerApplicationPaths.cs
index 2f57c97a1..dfdd4200e 100644
--- a/Emby.Server.Implementations/ServerApplicationPaths.cs
+++ b/Emby.Server.Implementations/ServerApplicationPaths.cs
@@ -9,8 +9,6 @@ namespace Emby.Server.Implementations
/// </summary>
public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths
{
- private string _internalMetadataPath;
-
/// <summary>
/// Initializes a new instance of the <see cref="ServerApplicationPaths" /> class.
/// </summary>
@@ -27,6 +25,7 @@ namespace Emby.Server.Implementations
cacheDirectoryPath,
webDirectoryPath)
{
+ InternalMetadataPath = DefaultInternalMetadataPath;
}
/// <summary>
@@ -98,12 +97,11 @@ namespace Emby.Server.Implementations
/// <value>The user configuration directory path.</value>
public string UserConfigurationDirectoryPath => Path.Combine(ConfigurationDirectoryPath, "users");
+ /// <inheritdoc/>
+ public string DefaultInternalMetadataPath => Path.Combine(ProgramDataPath, "metadata");
+
/// <inheritdoc />
- public string InternalMetadataPath
- {
- get => _internalMetadataPath ?? (_internalMetadataPath = Path.Combine(DataPath, "metadata"));
- set => _internalMetadataPath = value;
- }
+ public string InternalMetadataPath { get; set; }
/// <inheritdoc />
public string VirtualInternalMetadataPath { get; } = "%MetadataPath%";
diff --git a/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs b/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs
index ccf965898..89740ae08 100644
--- a/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs
+++ b/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs
@@ -1,3 +1,4 @@
+using System;
using System.IO;
using MediaBrowser.Model.Configuration;
@@ -17,18 +18,25 @@ namespace MediaBrowser.Common.Configuration
=> configurationManager.GetConfiguration<EncodingOptions>("encoding");
/// <summary>
- /// Retrieves the transcoding temp path from the encoding configuration.
+ /// Retrieves the transcoding temp path from the encoding configuration, falling back to a default if no path
+ /// is specified in configuration. If the directory does not exist, it will be created.
/// </summary>
- /// <param name="configurationManager">The Configuration manager.</param>
+ /// <param name="configurationManager">The configuration manager.</param>
/// <returns>The transcoding temp path.</returns>
+ /// <exception cref="UnauthorizedAccessException">If the directory does not exist, and the caller does not have the required permission to create it.</exception>
+ /// <exception cref="NotSupportedException">If there is a custom path transcoding path specified, but it is invalid.</exception>
+ /// <exception cref="IOException">If the directory does not exist, and it also could not be created.</exception>
public static string GetTranscodePath(this IConfigurationManager configurationManager)
{
+ // Get the configured path and fall back to a default
var transcodingTempPath = configurationManager.GetEncodingOptions().TranscodingTempPath;
if (string.IsNullOrEmpty(transcodingTempPath))
{
- return Path.Combine(configurationManager.CommonApplicationPaths.ProgramDataPath, "transcodes");
+ transcodingTempPath = Path.Combine(configurationManager.CommonApplicationPaths.ProgramDataPath, "transcodes");
}
+ // Make sure the directory exists
+ Directory.CreateDirectory(transcodingTempPath);
return transcodingTempPath;
}
}
diff --git a/MediaBrowser.Controller/IServerApplicationPaths.cs b/MediaBrowser.Controller/IServerApplicationPaths.cs
index 5d7c60910..c35a22ac7 100644
--- a/MediaBrowser.Controller/IServerApplicationPaths.cs
+++ b/MediaBrowser.Controller/IServerApplicationPaths.cs
@@ -71,7 +71,12 @@ namespace MediaBrowser.Controller
string UserConfigurationDirectoryPath { get; }
/// <summary>
- /// Gets the internal metadata path.
+ /// Gets the default internal metadata path.
+ /// </summary>
+ string DefaultInternalMetadataPath { get; }
+
+ /// <summary>
+ /// Gets the internal metadata path, either a custom path or the default.
/// </summary>
/// <value>The internal metadata path.</value>
string InternalMetadataPath { get; }