From 2dfebd2147e63880b758c3f1a8166c5588aaf7d2 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 29 Jul 2013 19:12:16 -0700 Subject: [PATCH] moved update url from db to nzbdrone.config --- .../Configuration/ConfigServiceFixture.cs | 18 --------- .../UpdatePackageProviderFixture.cs | 4 +- .../Configuration/ConfigFileProvider.cs | 6 +++ NzbDrone.Core/Configuration/ConfigService.cs | 38 ------------------- .../Events/ConfigFileSavedEvent.cs | 6 +-- NzbDrone.Core/Configuration/IConfigService.cs | 9 ----- NzbDrone.Core/Update/InstallUpdateService.cs | 3 ++ NzbDrone.Core/Update/UpdatePackageProvider.cs | 4 +- 8 files changed, 14 insertions(+), 74 deletions(-) diff --git a/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs b/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs index fb695e9c5..aaf562c7f 100644 --- a/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs +++ b/NzbDrone.Core.Test/Configuration/ConfigServiceFixture.cs @@ -105,24 +105,6 @@ namespace NzbDrone.Core.Test.Configuration Subject.GetValue(key, value2).Should().Be(value2); } - - - [Test] - public void uguid_should_only_be_set_once() - { - var guid1 = Subject.UGuid; - var guid2 = Subject.UGuid; - - guid1.Should().Be(guid2); - } - - [Test] - public void uguid_should_return_valid_result_on_first_call() - { - var guid = Subject.UGuid; - guid.Should().NotBeEmpty(); - } - [Test] public void updating_a_vakye_should_update_its_value() { diff --git a/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs b/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs index fa0008226..0ccb1aabb 100644 --- a/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs +++ b/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs @@ -10,11 +10,11 @@ namespace NzbDrone.Core.Test.UpdateTests public class UpdatePackageProviderFixture : CoreTest { [Test] - public void should_get_list_of_avilable_updates() + public void should_get_list_of_available_updates() { UseRealHttp(); - Mocker.GetMock().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_release/"); + Mocker.GetMock().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_release/"); var updates = Subject.GetAvailablePackages().ToList(); diff --git a/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 7e37a2ea4..703d8c426 100644 --- a/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -22,6 +22,7 @@ namespace NzbDrone.Core.Configuration string Username { get; } string Password { get; } string LogLevel { get; } + string UpdateUrl { get; } } public class ConfigFileProvider : IConfigFileProvider @@ -95,6 +96,11 @@ namespace NzbDrone.Core.Configuration get { return GetValueBoolean("AuthenticationEnabled", false); } } + public string UpdateUrl + { + get { return GetValue("UpdateUrl", "http://update.nzbdrone.com/vnext/"); } + } + public string Username { get { return GetValue("Username", ""); } diff --git a/NzbDrone.Core/Configuration/ConfigService.cs b/NzbDrone.Core/Configuration/ConfigService.cs index dade25f74..18a02490b 100644 --- a/NzbDrone.Core/Configuration/ConfigService.cs +++ b/NzbDrone.Core/Configuration/ConfigService.cs @@ -5,7 +5,6 @@ using NLog; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Clients.Nzbget; using NzbDrone.Core.Download.Clients.Sabnzbd; -using NzbDrone.Core.Instrumentation; namespace NzbDrone.Core.Configuration { @@ -137,11 +136,6 @@ namespace NzbDrone.Core.Configuration set { SetValue("SeasonFolderFormat", value); } } - public string UpdateUrl - { - get { return GetValue("UpdateUrl", "http://update.nzbdrone.com/vnext/"); } - set { SetValue("UpdateUrl", value); } - } public bool AutoUnmonitorPreviouslyDownloadedEpisodes { @@ -155,11 +149,6 @@ namespace NzbDrone.Core.Configuration set { SetValue("Retention", value); } } - public Guid UGuid - { - get { return Guid.Parse(GetValue("UGuid", Guid.NewGuid().ToString(), persist: true)); } - } - public DownloadClientType DownloadClient { get { return GetValueEnum("DownloadClient", DownloadClientType.Sabnzbd); } @@ -178,13 +167,6 @@ namespace NzbDrone.Core.Configuration get { return "http://services.nzbdrone.com"; } } - public Boolean MetadataUseBanners - { - get { return GetValueBoolean("MetadataUseBanners"); } - - set { SetValue("MetadataUseBanners", value); } - } - public string PneumaticFolder { get { return GetValue("PneumaticFolder", String.Empty); } @@ -197,19 +179,6 @@ namespace NzbDrone.Core.Configuration set { SetValue("RecycleBin", value); } } - public int RssSyncInterval - { - get { return GetValueInt("RssSyncInterval", 15); } - set { SetValue("RssSyncInterval", value); } - } - - public Boolean IgnoreArticlesWhenSortingSeries - { - get { return GetValueBoolean("IgnoreArticlesWhenSortingSeries", true); } - - set { SetValue("IgnoreArticlesWhenSortingSeries", value); } - } - public String NzbgetUsername { get { return GetValue("NzbgetUsername", "nzbget"); } @@ -245,13 +214,6 @@ namespace NzbDrone.Core.Configuration set { SetValue("NzbgetTvCategory", value); } } - public Int32 NzbgetPriority - { - get { return GetValueInt("NzbgetPriority", 0); } - - set { SetValue("NzbgetPriority", value); } - } - public PriorityType NzbgetRecentTvPriority { get { return GetValueEnum("NzbgetRecentTvPriority", PriorityType.Normal); } diff --git a/NzbDrone.Core/Configuration/Events/ConfigFileSavedEvent.cs b/NzbDrone.Core/Configuration/Events/ConfigFileSavedEvent.cs index 97db618ee..55b245855 100644 --- a/NzbDrone.Core/Configuration/Events/ConfigFileSavedEvent.cs +++ b/NzbDrone.Core/Configuration/Events/ConfigFileSavedEvent.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NzbDrone.Common.Messaging; +using NzbDrone.Common.Messaging; namespace NzbDrone.Core.Configuration.Events { diff --git a/NzbDrone.Core/Configuration/IConfigService.cs b/NzbDrone.Core/Configuration/IConfigService.cs index a16470791..3cb7a7fee 100644 --- a/NzbDrone.Core/Configuration/IConfigService.cs +++ b/NzbDrone.Core/Configuration/IConfigService.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using NzbDrone.Core.Download; using NzbDrone.Core.Download.Clients.Nzbget; using NzbDrone.Core.Download.Clients.Sabnzbd; -using NzbDrone.Core.Instrumentation; namespace NzbDrone.Core.Configuration { @@ -11,7 +10,6 @@ namespace NzbDrone.Core.Configuration { IEnumerable All(); Dictionary AllWithDefaults(); - string UpdateUrl { get; set; } String SabHost { get; set; } int SabPort { get; set; } String SabApiKey { get; set; } @@ -25,26 +23,19 @@ namespace NzbDrone.Core.Configuration string SeasonFolderFormat { get; set; } bool AutoUnmonitorPreviouslyDownloadedEpisodes { get; set; } int Retention { get; set; } - Guid UGuid { get; } DownloadClientType DownloadClient { get; set; } string BlackholeFolder { get; set; } string ServiceRootUrl { get; } - Boolean MetadataUseBanners { get; set; } string PneumaticFolder { get; set; } string RecycleBin { get; set; } - int RssSyncInterval { get; set; } - Boolean IgnoreArticlesWhenSortingSeries { get; set; } String NzbgetUsername { get; set; } String NzbgetPassword { get; set; } String NzbgetHost { get; set; } Int32 NzbgetPort { get; set; } String NzbgetTvCategory { get; set; } - Int32 NzbgetPriority { get; set; } PriorityType NzbgetRecentTvPriority { get; set; } PriorityType NzbgetOlderTvPriority { get; set; } string ReleaseRestrictions { get; set; } - string GetValue(string key, object defaultValue, bool persist = false); - void SetValue(string key, string value); void SaveValues(Dictionary configValues); } } diff --git a/NzbDrone.Core/Update/InstallUpdateService.cs b/NzbDrone.Core/Update/InstallUpdateService.cs index 3ba9541c3..43bc388d4 100644 --- a/NzbDrone.Core/Update/InstallUpdateService.cs +++ b/NzbDrone.Core/Update/InstallUpdateService.cs @@ -2,8 +2,10 @@ using System.IO; using NLog; using NzbDrone.Common; +using NzbDrone.Common.Cache; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Messaging; +using NzbDrone.Core.Configuration; using NzbDrone.Core.Update.Commands; namespace NzbDrone.Core.Update @@ -33,6 +35,7 @@ namespace NzbDrone.Core.Update _logger = logger; } + public void Execute(ApplicationUpdateCommand message) { var latestAvailable = _checkUpdateService.AvailableUpdate(); diff --git a/NzbDrone.Core/Update/UpdatePackageProvider.cs b/NzbDrone.Core/Update/UpdatePackageProvider.cs index e8b2b0f23..95fc23543 100644 --- a/NzbDrone.Core/Update/UpdatePackageProvider.cs +++ b/NzbDrone.Core/Update/UpdatePackageProvider.cs @@ -16,13 +16,13 @@ namespace NzbDrone.Core.Update public class UpdatePackageProvider : IUpdatePackageProvider { - private readonly IConfigService _configService; + private readonly IConfigFileProvider _configService; private readonly IHttpProvider _httpProvider; private readonly Logger _logger; private static readonly Regex ParseRegex = new Regex(@"(?:\>)(?NzbDrone.+?(?\d+\.\d+\.\d+\.\d+).+?)(?:\<\/A\>)", RegexOptions.IgnoreCase); - public UpdatePackageProvider(IConfigService configService, IHttpProvider httpProvider, Logger logger) + public UpdatePackageProvider(IConfigFileProvider configService, IHttpProvider httpProvider, Logger logger) { _configService = configService; _httpProvider = httpProvider;