Merge pull request #756 from Bond-009/cachedir

Make cache dir configurable
This commit is contained in:
Joshua M. Boniface 2019-02-01 20:33:00 -05:00 committed by GitHub
commit 021a1887fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 4 deletions

View File

@ -16,12 +16,14 @@ namespace Emby.Server.Implementations.AppBase
string programDataPath, string programDataPath,
string appFolderPath, string appFolderPath,
string logDirectoryPath = null, string logDirectoryPath = null,
string configurationDirectoryPath = null) string configurationDirectoryPath = null,
string cacheDirectoryPath = null)
{ {
ProgramDataPath = programDataPath; ProgramDataPath = programDataPath;
ProgramSystemPath = appFolderPath; ProgramSystemPath = appFolderPath;
LogDirectoryPath = logDirectoryPath; LogDirectoryPath = logDirectoryPath;
ConfigurationDirectoryPath = configurationDirectoryPath; ConfigurationDirectoryPath = configurationDirectoryPath;
CachePath = cacheDirectoryPath;
} }
public string ProgramDataPath { get; private set; } public string ProgramDataPath { get; private set; }

View File

@ -18,8 +18,13 @@ namespace Emby.Server.Implementations
string appFolderPath, string appFolderPath,
string applicationResourcesPath, string applicationResourcesPath,
string logDirectoryPath = null, string logDirectoryPath = null,
string configurationDirectoryPath = null) string configurationDirectoryPath = null,
: base(programDataPath, appFolderPath, logDirectoryPath, configurationDirectoryPath) string cacheDirectoryPath = null)
: base(programDataPath,
appFolderPath,
logDirectoryPath,
configurationDirectoryPath,
cacheDirectoryPath)
{ {
ApplicationResourcesPath = applicationResourcesPath; ApplicationResourcesPath = applicationResourcesPath;
} }

View File

@ -202,6 +202,31 @@ namespace Jellyfin.Server
Directory.CreateDirectory(configDir); Directory.CreateDirectory(configDir);
} }
string cacheDir = Environment.GetEnvironmentVariable("JELLYFIN_CACHE_DIR");
if (string.IsNullOrEmpty(cacheDir))
{
if (options.CacheDir != null)
{
cacheDir = options.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"); string logDir = Environment.GetEnvironmentVariable("JELLYFIN_LOG_DIR");
if (string.IsNullOrEmpty(logDir)) if (string.IsNullOrEmpty(logDir))
{ {
@ -223,7 +248,7 @@ namespace Jellyfin.Server
string appPath = AppContext.BaseDirectory; string 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) private static async Task createLogger(IApplicationPaths appPaths)

View File

@ -11,6 +11,9 @@ namespace Jellyfin.Server
[Option('d', "datadir", Required = false, HelpText = "Path to use for the data folder (database files, etc.).")] [Option('d', "datadir", Required = false, HelpText = "Path to use for the data folder (database files, etc.).")]
public string DataDir { get; set; } public string DataDir { get; set; }
[Option('C', "cachedir", Required = false, HelpText = "Path to use for caching.")]
public string CacheDir { get; set; }
[Option('c', "configdir", Required = false, HelpText = "Path to use for configuration data (user settings and pictures).")] [Option('c', "configdir", Required = false, HelpText = "Path to use for configuration data (user settings and pictures).")]
public string ConfigDir { get; set; } public string ConfigDir { get; set; }