diff options
| author | Joshua M. Boniface <joshua@boniface.me> | 2019-02-01 20:33:00 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-01 20:33:00 -0500 |
| commit | 021a1887fbda4d63818af98b8848111c32376926 (patch) | |
| tree | 3bf441e681bd1b610b96f73aa9de72407200e6cf /Jellyfin.Server/Program.cs | |
| parent | b4c5ff89fd94d216c180a56c370e77e7fecfd93e (diff) | |
| parent | fa3a8108e5c215b3481306f1679432e6b337f6d3 (diff) | |
Merge pull request #756 from Bond-009/cachedir
Make cache dir configurable
Diffstat (limited to 'Jellyfin.Server/Program.cs')
| -rw-r--r-- | Jellyfin.Server/Program.cs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 2f1828336..5c8608a92 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.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"); 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) |
