diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
index 0ff70deca..a6eaf2d0a 100644
--- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
+++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs
@@ -67,11 +67,15 @@ namespace Emby.Server.Implementations.Configuration
///
/// Updates the metadata path.
///
+ /// If the directory does not exist, and the caller does not have the required permission to create it.
+ /// If there is a custom path transcoding path specified, but it is invalid.
+ /// If the directory does not exist, and it also could not be created.
private void UpdateMetadataPath()
{
((ServerApplicationPaths)ApplicationPaths).InternalMetadataPath = string.IsNullOrWhiteSpace(Configuration.MetadataPath)
- ? Path.Combine(ApplicationPaths.ProgramDataPath, "metadata")
+ ? ApplicationPaths.DefaultInternalMetadataPath
: Configuration.MetadataPath;
+ Directory.CreateDirectory(ApplicationPaths.InternalMetadataPath);
}
///
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
///
public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths
{
- private string _internalMetadataPath;
-
///
/// Initializes a new instance of the class.
///
@@ -27,6 +25,7 @@ namespace Emby.Server.Implementations
cacheDirectoryPath,
webDirectoryPath)
{
+ InternalMetadataPath = DefaultInternalMetadataPath;
}
///
@@ -98,12 +97,11 @@ namespace Emby.Server.Implementations
/// The user configuration directory path.
public string UserConfigurationDirectoryPath => Path.Combine(ConfigurationDirectoryPath, "users");
+ ///
+ public string DefaultInternalMetadataPath => Path.Combine(ProgramDataPath, "metadata");
+
///
- public string InternalMetadataPath
- {
- get => _internalMetadataPath ?? (_internalMetadataPath = Path.Combine(DataPath, "metadata"));
- set => _internalMetadataPath = value;
- }
+ public string InternalMetadataPath { get; set; }
///
public string VirtualInternalMetadataPath { get; } = "%MetadataPath%";
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; }
///
- /// Gets the internal metadata path.
+ /// Gets the default internal metadata path.
+ ///
+ string DefaultInternalMetadataPath { get; }
+
+ ///
+ /// Gets the internal metadata path, either a custom path or the default.
///
/// The internal metadata path.
string InternalMetadataPath { get; }