From 8c372e938cfec9944d6052721150f925d4f36e21 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 16 May 2011 00:32:01 -0700 Subject: [PATCH] fixed some settings value convert issues. would cause crash on clean installs. --- NzbDrone.Core.Test/SabControllerTest.cs | 14 +++++----- .../Providers/Core/ConfigProvider.cs | 23 ++++++++-------- NzbDrone.Core/Providers/SabProvider.cs | 2 +- .../Controllers/SettingsController.cs | 27 +++++++++---------- NzbDrone/Program.cs | 11 ++++++-- 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/NzbDrone.Core.Test/SabControllerTest.cs b/NzbDrone.Core.Test/SabControllerTest.cs index 7d2a7763e..68e92c855 100644 --- a/NzbDrone.Core.Test/SabControllerTest.cs +++ b/NzbDrone.Core.Test/SabControllerTest.cs @@ -21,11 +21,11 @@ namespace NzbDrone.Core.Test { //Setup string sabHost = "192.168.5.55"; - string sabPort = "2222"; + int sabPort = 2222; string apikey = "5c770e3197e4fe763423ee7c392c25d1"; string username = "admin"; string password = "pass"; - string priority = "Normal"; + var priority = SabnzbdPriorityType.Normal; string category = "tv"; @@ -67,11 +67,11 @@ namespace NzbDrone.Core.Test { //Setup string sabHost = "192.168.5.55"; - string sabPort = "2222"; + int sabPort = 2222; string apikey = "5c770e3197e4fe763423ee7c392c25d1"; string username = "admin"; string password = "pass"; - string priority = "Normal"; + var priority = SabnzbdPriorityType.Normal; string category = "tv"; var mocker = new AutoMoqer(); @@ -108,7 +108,7 @@ namespace NzbDrone.Core.Test { //Setup string sabHost = "192.168.5.55"; - string sabPort = "2222"; + int sabPort = 2222; string apikey = "5c770e3197e4fe763423ee7c392c25d1"; string username = "admin"; string password = "pass"; @@ -143,7 +143,7 @@ namespace NzbDrone.Core.Test { //Setup string sabHost = "192.168.5.55"; - string sabPort = "2222"; + int sabPort = 2222; string apikey = "5c770e3197e4fe763423ee7c392c25d1"; string username = "admin"; string password = "pass"; @@ -179,7 +179,7 @@ namespace NzbDrone.Core.Test { //Setup string sabHost = "192.168.5.55"; - string sabPort = "2222"; + int sabPort = 2222; string apikey = "5c770e3197e4fe763423ee7c392c25d1"; string username = "admin"; string password = "pass"; diff --git a/NzbDrone.Core/Providers/Core/ConfigProvider.cs b/NzbDrone.Core/Providers/Core/ConfigProvider.cs index c369e87f6..0e74c2f1f 100644 --- a/NzbDrone.Core/Providers/Core/ConfigProvider.cs +++ b/NzbDrone.Core/Providers/Core/ConfigProvider.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using NLog; +using NzbDrone.Core.Model; using NzbDrone.Core.Repository; using SubSonic.Repository; @@ -103,23 +104,23 @@ namespace NzbDrone.Core.Providers.Core set { SetValue("NewzbinPassword", value); } } - public virtual String SyncFrequency + public virtual int SyncFrequency { - get { return GetValue("SyncFrequency"); } + get { return GetValueInt("SyncFrequency"); } set { SetValue("SyncFrequency", value); } } - public virtual String DownloadPropers + public virtual Boolean DownloadPropers { - get { return GetValue("DownloadPropers"); } + get { return GetValueBoolean("DownloadPropers"); } set { SetValue("DownloadPropers", value); } } - public virtual String Retention + public virtual Int32 Retention { - get { return GetValue("Retention"); } + get { return GetValueInt("Retention"); } set { SetValue("Retention", value); } } @@ -131,9 +132,9 @@ namespace NzbDrone.Core.Providers.Core set { SetValue("SabHost", value); } } - public virtual String SabPort + public virtual int SabPort { - get { return GetValue("SabPort"); } + get { return GetValueInt("SabPort"); } set { SetValue("SabPort", value); } } @@ -166,11 +167,11 @@ namespace NzbDrone.Core.Providers.Core set { SetValue("SabTvCategory", value); } } - public virtual String SabTvPriority + public virtual SabnzbdPriorityType SabTvPriority { - get { return GetValue("SabTvPriority"); } + get { return (SabnzbdPriorityType)GetValueInt("SabTvPriority"); } - set { SetValue("SabTvPriority", value); } + set { SetValue("SabTvPriority", (int)value); } } public virtual Boolean UseBlackhole diff --git a/NzbDrone.Core/Providers/SabProvider.cs b/NzbDrone.Core/Providers/SabProvider.cs index 8669007f4..418f756b2 100644 --- a/NzbDrone.Core/Providers/SabProvider.cs +++ b/NzbDrone.Core/Providers/SabProvider.cs @@ -29,7 +29,7 @@ namespace NzbDrone.Core.Providers public virtual bool AddByUrl(string url, string title) { string cat = _configProvider.SabTvCategory; - int priority = (int)Enum.Parse(typeof(SabnzbdPriorityType), _configProvider.SabTvPriority); + int priority = (int)_configProvider.SabTvPriority; string name = url.Replace("&", "%26"); string nzbName = HttpUtility.UrlEncode(title); diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 4fb6dc6f1..9726b1a89 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -106,20 +106,17 @@ namespace NzbDrone.Web.Controllers var model = new DownloadSettingsModel { - SyncFrequency = Convert.ToInt32(_configProvider.SyncFrequency), - DownloadPropers = Convert.ToBoolean(_configProvider.DownloadPropers), - Retention = Convert.ToInt32(_configProvider.Retention), + SyncFrequency = _configProvider.SyncFrequency, + DownloadPropers = _configProvider.DownloadPropers, + Retention = _configProvider.Retention, SabHost = _configProvider.SabHost, - SabPort = Convert.ToInt32(_configProvider.SabPort), + SabPort =_configProvider.SabPort, SabApiKey = _configProvider.SabApiKey, SabUsername = _configProvider.SabUsername, SabPassword = _configProvider.SabPassword, SabTvCategory = _configProvider.SabTvCategory, - SabTvPriority = - (SabnzbdPriorityType) - Enum.Parse(typeof(SabnzbdPriorityType), - _configProvider.SabTvPriority), - UseBlackHole = Convert.ToBoolean(_configProvider.UseBlackhole), + SabTvPriority = _configProvider.SabTvPriority, + UseBlackHole = _configProvider.UseBlackhole, BlackholeDirectory = _configProvider.BlackholeDirectory }; @@ -374,7 +371,7 @@ namespace NzbDrone.Web.Controllers return Content(SETTINGS_FAILED); } - + basicNotification.Title = SETTINGS_SAVED; _notificationProvider.Register(basicNotification); @@ -437,16 +434,16 @@ namespace NzbDrone.Web.Controllers if (ModelState.IsValid) { - _configProvider.SyncFrequency = data.SyncFrequency.ToString(); - _configProvider.DownloadPropers = data.DownloadPropers.ToString(); - _configProvider.Retention = data.Retention.ToString(); + _configProvider.SyncFrequency = data.SyncFrequency; + _configProvider.DownloadPropers = data.DownloadPropers; + _configProvider.Retention = data.Retention; _configProvider.SabHost = data.SabHost; - _configProvider.SabPort = data.SabPort.ToString(); + _configProvider.SabPort = data.SabPort; _configProvider.SabApiKey = data.SabApiKey; _configProvider.SabPassword = data.SabPassword; _configProvider.SabTvCategory = data.SabTvCategory; _configProvider.SabUsername = data.SabUsername; - _configProvider.SabTvPriority = data.SabTvPriority.ToString(); + _configProvider.SabTvPriority = data.SabTvPriority; _configProvider.UseBlackhole = data.UseBlackHole; _configProvider.BlackholeDirectory = data.BlackholeDirectory; diff --git a/NzbDrone/Program.cs b/NzbDrone/Program.cs index 2a585add6..84e49ed48 100644 --- a/NzbDrone/Program.cs +++ b/NzbDrone/Program.cs @@ -37,8 +37,15 @@ namespace NzbDrone Attach(); #endif - Process.Start(IISController.AppUrl); - + try + { + Logger.Info("Starting default browser. {0}",IISController.AppUrl); + Process.Start(IISController.AppUrl); + } + catch(Exception e) + { + Logger.ErrorException("Failed to open URL in default browser.", e); + } while (true) { Console.ReadLine();