mirror of https://github.com/jellyfin/jellyfin.git
Merge pull request #851 from Bond-009/appdata
Simplify code to get data dir
This commit is contained in:
commit
50ce7572b4
|
@ -187,26 +187,13 @@ namespace Jellyfin.Server
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(dataDir))
|
if (string.IsNullOrEmpty(dataDir))
|
||||||
{
|
{
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
// LocalApplicationData follows the XDG spec on unix machines
|
||||||
{
|
dataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "jellyfin");
|
||||||
dataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// $XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored.
|
|
||||||
dataDir = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
|
|
||||||
|
|
||||||
// If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.
|
|
||||||
if (string.IsNullOrEmpty(dataDir))
|
|
||||||
{
|
|
||||||
dataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dataDir = Path.Combine(dataDir, "jellyfin");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Directory.CreateDirectory(dataDir);
|
||||||
|
|
||||||
// configDir
|
// configDir
|
||||||
// IF --configdir
|
// IF --configdir
|
||||||
// ELSE IF $JELLYFIN_CONFIG_DIR
|
// ELSE IF $JELLYFIN_CONFIG_DIR
|
||||||
|
@ -216,7 +203,6 @@ namespace Jellyfin.Server
|
||||||
// ELSE IF $XDG_CONFIG_HOME use $XDG_CONFIG_HOME/jellyfin
|
// ELSE IF $XDG_CONFIG_HOME use $XDG_CONFIG_HOME/jellyfin
|
||||||
// ELSE $HOME/.config/jellyfin
|
// ELSE $HOME/.config/jellyfin
|
||||||
var configDir = options.ConfigDir;
|
var configDir = options.ConfigDir;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(configDir))
|
if (string.IsNullOrEmpty(configDir))
|
||||||
{
|
{
|
||||||
configDir = Environment.GetEnvironmentVariable("JELLYFIN_CONFIG_DIR");
|
configDir = Environment.GetEnvironmentVariable("JELLYFIN_CONFIG_DIR");
|
||||||
|
@ -300,7 +286,6 @@ namespace Jellyfin.Server
|
||||||
// Ensure the main folders exist before we continue
|
// Ensure the main folders exist before we continue
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(dataDir);
|
|
||||||
Directory.CreateDirectory(logDir);
|
Directory.CreateDirectory(logDir);
|
||||||
Directory.CreateDirectory(configDir);
|
Directory.CreateDirectory(configDir);
|
||||||
Directory.CreateDirectory(cacheDir);
|
Directory.CreateDirectory(cacheDir);
|
||||||
|
|
Loading…
Reference in New Issue