From 95a5dd881076f6649f4b5dc5a1897df98dc3c008 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Tue, 1 Jan 2019 21:34:12 +0100 Subject: Fix log dir --- .../AppBase/BaseApplicationPaths.cs | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs') diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs index 52e421374..76d0076a6 100644 --- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs +++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using MediaBrowser.Common.Configuration; namespace Emby.Server.Implementations.AppBase @@ -13,10 +12,11 @@ namespace Emby.Server.Implementations.AppBase /// /// Initializes a new instance of the class. /// - protected BaseApplicationPaths(string programDataPath, string appFolderPath) + protected BaseApplicationPaths(string programDataPath, string appFolderPath, string logDirectoryPath) { ProgramDataPath = programDataPath; ProgramSystemPath = appFolderPath; + LogDirectoryPath = logDirectoryPath; } public string ProgramDataPath { get; private set; } @@ -106,6 +106,11 @@ namespace Emby.Server.Implementations.AppBase } } + /// + /// The _log directory + /// + private string _logDirectoryPath; + /// /// Gets the path to the log directory /// @@ -114,7 +119,18 @@ namespace Emby.Server.Implementations.AppBase { get { - return Path.Combine(ProgramDataPath, "logs"); + if (string.IsNullOrEmpty(_logDirectoryPath)) + { + _logDirectoryPath = Path.Combine(ProgramDataPath, "logs"); + + Directory.CreateDirectory(_logDirectoryPath); + } + + return _logDirectoryPath; + } + set + { + _logDirectoryPath = value; } } -- cgit v1.2.3 From 2850ff7b8afb2ab1a35c2797f88cef1bc0de8bd9 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sat, 5 Jan 2019 19:12:05 +0100 Subject: Make config path configurable --- .../AppBase/BaseApplicationPaths.cs | 25 +++++++++++++++++-- .../ServerApplicationPaths.cs | 9 +++++-- Jellyfin.Server/Program.cs | 28 +++++++++++++++++++++- 3 files changed, 57 insertions(+), 5 deletions(-) (limited to 'Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs') 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 /// /// Initializes a new instance of the class. /// - 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 } } + /// + /// The _config directory + /// + private string _configurationDirectoryPath; + /// /// Gets the path to the application configuration root directory /// @@ -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 /// /// Initializes a new instance of the class. /// - 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..d8a746304 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.Server string 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) -- cgit v1.2.3