diff options
| -rw-r--r-- | Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs | 25 | ||||
| -rw-r--r-- | Emby.Server.Implementations/ServerApplicationPaths.cs | 9 | ||||
| -rw-r--r-- | Jellyfin.Server/Program.cs | 73 |
3 files changed, 87 insertions, 20 deletions
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs index 76d0076a6..3e12bc0b6 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; } @@ -135,6 +140,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> /// <value>The configuration directory path.</value> @@ -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.cs index f5986f943..8a0f2671a 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.cs index 2dd4d9af6..eedc9f9ce 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -102,43 +102,84 @@ namespace Jellyfin.Server private static ServerApplicationPaths createApplicationPaths(StartupOptions options)
{
- string programDataPath;
- if (options.ContainsOption("-programdata"))
+ string programDataPath = Environment.GetEnvironmentVariable("JELLYFIN_DATA_PATH");
+ if (string.IsNullOrEmpty(programDataPath))
{
- programDataPath = options.GetOption("-programdata");
+ if (options.ContainsOption("-programdata"))
+ {
+ programDataPath = options.GetOption("-programdata");
+ }
+ else
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+ }
+ else
+ {
+ // $XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored.
+ programDataPath = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
+ // If $XDG_DATA_HOME is either not set or empty, $HOME/.local/share should be used.
+ if (string.IsNullOrEmpty(programDataPath))
+ {
+ programDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
+ }
+ }
+ programDataPath = Path.Combine(programDataPath, "jellyfin");
+ // Ensure the dir exists
+ Directory.CreateDirectory(programDataPath);
+ }
}
- else
+
+ string configDir = Environment.GetEnvironmentVariable("JELLYFIN_CONFIG_DIR");
+ if (string.IsNullOrEmpty(configDir))
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ if (options.ContainsOption("-configdir"))
{
- programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+ configDir = options.GetOption("-configdir");
}
else
{
- // $XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored.
- programDataPath = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
- // If $XDG_DATA_HOME is either not set or empty, $HOME/.local/share should be used.
- if (string.IsNullOrEmpty(programDataPath))
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- programDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
+ configDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
}
+ else
+ {
+ // $XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored.
+ configDir = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
+ // If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config should be used.
+ if (string.IsNullOrEmpty(configDir))
+ {
+ configDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
+ }
+ }
+ configDir = Path.Combine(configDir, "jellyfin");
+ // Ensure the dir exists
+ Directory.CreateDirectory(configDir);
}
- programDataPath = Path.Combine(programDataPath, "jellyfin");
}
string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");
if (string.IsNullOrEmpty(logDir))
{
- logDir = Path.Combine(programDataPath, "logs");
- // Ensure logDir exists
- Directory.CreateDirectory(logDir);
+ if (options.ContainsOption("-logdir"))
+ {
+ logDir = options.GetOption("-logdir");
+ }
+ else
+ {
+ logDir = Path.Combine(programDataPath, "logs");
+ // Ensure the dir exists
+ Directory.CreateDirectory(logDir);
+ }
// $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager
Environment.SetEnvironmentVariable("JELLYFIN_LOG_DIR", logDir);
}
string appPath = AppContext.BaseDirectory;
- return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir);
+ return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir, configDir);
}
private static async Task createLogger(IApplicationPaths appPaths)
|
