From 0f5c0cca3768efd106192add90090c893b2ea60c Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 12 Dec 2018 18:55:14 +0100 Subject: [PATCH] Move default folder for *nix platforms to $HOME/.jellyfin Remove dependency on System.Configuration.ConfigurationManager --- .../ApplicationPathHelper.cs | 60 ------------------- MediaBrowser.Server.Mono/EmbyServer.csproj | 1 - MediaBrowser.Server.Mono/Program.cs | 12 +++- MediaBrowser.Server.Mono/app.config | 7 --- 4 files changed, 10 insertions(+), 70 deletions(-) delete mode 100644 MediaBrowser.Server.Mono/ApplicationPathHelper.cs delete mode 100644 MediaBrowser.Server.Mono/app.config diff --git a/MediaBrowser.Server.Mono/ApplicationPathHelper.cs b/MediaBrowser.Server.Mono/ApplicationPathHelper.cs deleted file mode 100644 index ac55693fa2..0000000000 --- a/MediaBrowser.Server.Mono/ApplicationPathHelper.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Configuration; -using System.IO; -using System.Runtime.InteropServices; - -namespace MediaBrowser.Server.Mono -{ - public static class ApplicationPathHelper - { - /// - /// Gets the path to the application's ProgramDataFolder - /// - /// System.String. - 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; - } - } -} diff --git a/MediaBrowser.Server.Mono/EmbyServer.csproj b/MediaBrowser.Server.Mono/EmbyServer.csproj index cafee872b8..480b422bc2 100644 --- a/MediaBrowser.Server.Mono/EmbyServer.csproj +++ b/MediaBrowser.Server.Mono/EmbyServer.csproj @@ -22,7 +22,6 @@ - diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 3bcfff9831..8d0c9ee0ee 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -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,19 @@ namespace MediaBrowser.Server.Mono { if (string.IsNullOrEmpty(programDataPath)) { - programDataPath = ApplicationPathHelper.GetProgramDataPath(applicationPath); + if (InteropServices.RuntimeInformation.IsOSPlatform(InteropServices.OSPlatform.Windows)) + { + programDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "jellyfin"); + } + else + { + programDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".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) diff --git a/MediaBrowser.Server.Mono/app.config b/MediaBrowser.Server.Mono/app.config deleted file mode 100644 index a93871625f..0000000000 --- a/MediaBrowser.Server.Mono/app.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file