From 7cbad21e0b5f5e60788e3e0a28c1f34758e650ec Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 11 Jul 2015 10:29:20 -0600 Subject: [PATCH] Changed app settings location to longer require root on unix --- src/Jackett/Program.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Jackett/Program.cs b/src/Jackett/Program.cs index 52c0d18d5..08bd34a40 100644 --- a/src/Jackett/Program.cs +++ b/src/Jackett/Program.cs @@ -18,7 +18,7 @@ namespace Jackett { class Program { - public static string AppConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Jackett"); + public static string AppConfigDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Jackett"); public static Server ServerInstance { get; private set; } @@ -36,6 +36,8 @@ namespace Jackett { ExitEvent = new ManualResetEvent(false); + MigrateSettingsDirectory(); + try { if (!Directory.Exists(AppConfigDirectory)) @@ -111,6 +113,22 @@ namespace Jackett Console.WriteLine("Server thread exit"); } + static void MigrateSettingsDirectory() + { + try + { + string oldDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Jackett"); + if (Directory.Exists(oldDir) && !Directory.Exists(AppConfigDirectory)) + { + Directory.Move(oldDir, AppConfigDirectory); + } + } + catch (Exception ex) + { + Console.WriteLine("ERROR could not migrate settings directory " + ex); + } + } + static void ReadSettingsFile() { var path = Path.Combine(AppConfigDirectory, "config.json");