aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2019-01-28 17:52:56 +0100
committerBond_009 <bond.009@outlook.com>2019-02-01 18:13:18 +0100
commit8af1e93cd4c9187ec46e2a6c7002791190be13fc (patch)
treea4d50263f1b9dd84e656c3903cd3c164b18b8b07 /Jellyfin.Server
parentb4c5ff89fd94d216c180a56c370e77e7fecfd93e (diff)
Make cache dir configurable
Diffstat (limited to 'Jellyfin.Server')
-rw-r--r--Jellyfin.Server/Program.cs27
1 files changed, 26 insertions, 1 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs
index 2f1828336..e0d5ed623 100644
--- a/Jellyfin.Server/Program.cs
+++ b/Jellyfin.Server/Program.cs
@@ -202,6 +202,31 @@ namespace Jellyfin.Server
Directory.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.Server
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)