The Free Software Media System - Server Backend & API
Make cache dir configurable
Bond_0098af1e93cd4c9
diff --git a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.csindex e4a2cd9dff..701c04f9e2 100644--- a/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs+++ b/Emby.Server.Implementations/AppBase/BaseApplicationPaths.cs@@ -16,12 +16,14 @@ namespace Emby.Server.Implementations.AppBasestring programDataPath,string appFolderPath,string logDirectoryPath = null,- string configurationDirectoryPath = null)+ string configurationDirectoryPath = null,+ string cacheDirectoryPath = null){ProgramDataPath = programDataPath;ProgramSystemPath = appFolderPath;LogDirectoryPath = logDirectoryPath;ConfigurationDirectoryPath = configurationDirectoryPath;+ CachePath = cacheDirectoryPath;}public string ProgramDataPath { get; private set; }diff --git a/Emby.Server.Implementations/ServerApplicationPaths.cs b/Emby.Server.Implementations/ServerApplicationPaths.csindex 67389536bf..36975df50c 100644--- a/Emby.Server.Implementations/ServerApplicationPaths.cs+++ b/Emby.Server.Implementations/ServerApplicationPaths.cs@@ -18,8 +18,13 @@ namespace Emby.Server.Implementationsstring appFolderPath,string applicationResourcesPath,string logDirectoryPath = null,- string configurationDirectoryPath = null)- : base(programDataPath, appFolderPath, logDirectoryPath, configurationDirectoryPath)+ string configurationDirectoryPath = null,+ string cacheDirectoryPath = null)+ : base(programDataPath,+ appFolderPath,+ logDirectoryPath,+ configurationDirectoryPath,+ cacheDirectoryPath){ApplicationResourcesPath = applicationResourcesPath;}diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.csindex 2f18283360..e0d5ed6239 100644--- a/Jellyfin.Server/Program.cs+++ b/Jellyfin.Server/Program.cs@@ -202,6 +202,31 @@ namespace Jellyfin.ServerDirectory.CreateDirectory(configDir);}+ string cacheDir = Environment.GetEnvironmentVariable("JELLYFIN_CACHE_DIR");+ if (string.IsNullOrEmpty(cacheDir))+ {+ if (options.ContainsOption("-cachedir"))+ {+ cacheDir = options.GetOption("-cachedir");+ }+ else if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))+ {+ // $XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored.+ cacheDir = Environment.GetEnvironmentVariable("XDG_CACHE_HOME");+ // If $XDG_CACHE_HOME is either not set or empty, $HOME/.cache should be used.+ if (string.IsNullOrEmpty(cacheDir))+ {+ cacheDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".cache");+ }+ cacheDir = Path.Combine(cacheDir, "jellyfin");+ }+ }++ if (cacheDir != null)+ {+ Directory.CreateDirectory(cacheDir);+ }+string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");if (string.IsNullOrEmpty(logDir)){@@ -223,7 +248,7 @@ namespace Jellyfin.Serverstring appPath = AppContext.BaseDirectory;- return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir, configDir);+ return new ServerApplicationPaths(programDataPath, appPath, appPath, logDir, configDir, cacheDir);}private static async Task createLogger(IApplicationPaths appPaths)