Merge pull request #97 from Bond-009/home

Move default data folder for *nix platforms to $XDG_DATA_HOME/jellyfin
pull/1154/head
Andrew Rabert 6 years ago committed by GitHub
commit bdc2655a78

@ -1,60 +0,0 @@
using System;
using System.Configuration;
using System.IO;
using System.Runtime.InteropServices;
namespace MediaBrowser.Server.Mono
{
public static class ApplicationPathHelper
{
/// <summary>
/// Gets the path to the application's ProgramDataFolder
/// </summary>
/// <returns>System.String.</returns>
public static string GetProgramDataPath(string applicationPath)
{
var useDebugPath = false;
#if DEBUG
useDebugPath = true;
#endif
var programDataPath = useDebugPath ?
ConfigurationManager.AppSettings["DebugProgramDataPath"] :
ConfigurationManager.AppSettings["ReleaseProgramDataPath"];
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
programDataPath = programDataPath.Replace("%ApplicationData%", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
}
else
{
programDataPath = programDataPath.Replace("%ApplicationData%", "/var/lib");
}
programDataPath = programDataPath
.Replace('/', Path.DirectorySeparatorChar)
.Replace('\\', Path.DirectorySeparatorChar);
// If it's a relative path, e.g. "..\"
if (!Path.IsPathRooted(programDataPath))
{
var path = Path.GetDirectoryName(applicationPath);
if (string.IsNullOrEmpty(path))
{
throw new ApplicationException("Unable to determine running assembly location");
}
programDataPath = Path.Combine(path, programDataPath);
programDataPath = Path.GetFullPath(programDataPath);
}
Directory.CreateDirectory(programDataPath);
return programDataPath;
}
}
}

@ -22,7 +22,6 @@
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="1.1.11" />
<PackageReference Include="SQLitePCLRaw.core" Version="1.1.11" />
<PackageReference Include="SQLitePCLRaw.provider.sqlite3.netstandard11" Version="1.1.11" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
</ItemGroup>
<ItemGroup>

@ -24,6 +24,7 @@ using Mono.Unix.Native;
using ILogger = MediaBrowser.Model.Logging.ILogger;
using X509Certificate = System.Security.Cryptography.X509Certificates.X509Certificate;
using System.Threading;
using InteropServices = System.Runtime.InteropServices;
namespace MediaBrowser.Server.Mono
{
@ -87,12 +88,26 @@ namespace MediaBrowser.Server.Mono
{
if (string.IsNullOrEmpty(programDataPath))
{
programDataPath = ApplicationPathHelper.GetProgramDataPath(applicationPath);
if (InteropServices.RuntimeInformation.IsOSPlatform(InteropServices.OSPlatform.Windows))
{
programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
}
else
{
// $XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored.
programDataPath = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
// If $XDG_DATA_HOME is either not set or empty, $HOME/.local/share should be used.
if (string.IsNullOrEmpty(programDataPath)){
programDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
}
}
}
programDataPath = Path.Combine(programDataPath, "jellyfin");
var appFolderPath = Path.GetDirectoryName(applicationPath);
return new ServerApplicationPaths(programDataPath, appFolderPath, Path.GetDirectoryName(applicationPath));
return new ServerApplicationPaths(programDataPath, appFolderPath, appFolderPath);
}
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, StartupOptions options)

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="DebugProgramDataPath" value="%ApplicationData%/jellyfin-debug/" />
<add key="ReleaseProgramDataPath" value="%ApplicationData%/jellyfin/" />
</appSettings>
</configuration>
Loading…
Cancel
Save