The Free Software Media System - Server Backend & API
Make config path configurable
Bond_0092850ff7b8afb
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.csindex 76d0076a66..3e12bc0b6e 100644--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs@@ -12,11 +12,16 @@ namespace Emby.Server.Implementations.AppBase/// <summary>/// Initializes a new instance of the <see cref="BaseApplicationPaths"/> class./// </summary>- protected BaseApplicationPaths(string programDataPath, string appFolderPath, string logDirectoryPath)+ protected BaseApplicationPaths(+ string programDataPath,+ string appFolderPath,+ string logDirectoryPath = null,+ string configurationDirectoryPath = null){ProgramDataPath = programDataPath;ProgramSystemPath = appFolderPath;LogDirectoryPath = logDirectoryPath;+ ConfigurationDirectoryPath = configurationDirectoryPath;}public string ProgramDataPath { get; private set; }@@ -134,6 +139,11 @@ namespace Emby.Server.Implementations.AppBase}}+ /// <summary>+ /// The _config directory+ /// </summary>+ private string _configurationDirectoryPath;+/// <summary>/// Gets the path to the application configuration root directory/// </summary>@@ -142,7 +152,18 @@ namespace Emby.Server.Implementations.AppBase{get{- return Path.Combine(ProgramDataPath, "config");+ if (string.IsNullOrEmpty(_configurationDirectoryPath))+ {+ _configurationDirectoryPath = Path.Combine(ProgramDataPath, "config");++ Directory.CreateDirectory(_configurationDirectoryPath);+ }++ return _configurationDirectoryPath;+ }+ set+ {+ _configurationDirectoryPath = value;}}diff --git a/Emby.Server.Implementations/ServerApplicationPaths.cs b/Emby.Server.Implementations/ServerApplicationPaths.csindex f5986f9433..8a0f2671ac 100644--- a/Emby.Server.Implementations/ServerApplicationPaths.cs+++ b/Emby.Server.Implementations/ServerApplicationPaths.cs@@ -13,8 +13,13 @@ namespace Emby.Server.Implementations/// <summary>/// Initializes a new instance of the <see cref="BaseApplicationPaths" /> class./// </summary>- public ServerApplicationPaths(string programDataPath, string appFolderPath, string applicationResourcesPath, string logDirectoryPath = null)- : base(programDataPath, appFolderPath, logDirectoryPath)+ public ServerApplicationPaths(+ string programDataPath,+ string appFolderPath,+ string applicationResourcesPath,+ string logDirectoryPath = null,+ string configurationDirectoryPath = null)+ : base(programDataPath, appFolderPath, logDirectoryPath, configurationDirectoryPath){ApplicationResourcesPath = applicationResourcesPath;}diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.csindex 2dd4d9af66..d8a7463043 100644--- a/Jellyfin.Server/Program.cs+++ b/Jellyfin.Server/Program.cs@@ -124,6 +124,32 @@ namespace Jellyfin.Server}}programDataPath = Path.Combine(programDataPath, "jellyfin");+ Directory.CreateDirectory(programDataPath);+ }++ string configPath;+ if (options.ContainsOption("-configpath"))+ {+ configPath = options.GetOption("-configpath");+ }+ else+ {+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))+ {+ configPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);+ }+ else+ {+ // $XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored.+ configPath = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");+ // If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config should be used.+ if (string.IsNullOrEmpty(configPath))+ {+ configPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");+ }+ }+ configPath = Path.Combine(configPath, "jellyfin");+ Directory.CreateDirectory(configPath);}string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");@@ -138,7 +164,7 @@ namespace Jellyfin.Serverstring appPath = AppContext.BaseDirectory;- return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir);+ return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir, configPath);}private static async Task createLogger(IApplicationPaths appPaths)