diff --git a/src/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs b/src/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs index cece2dedc..fc192a08a 100644 --- a/src/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs +++ b/src/NzbDrone.Core.Test/UpdateTests/UpdatePackageProviderFixture.cs @@ -23,6 +23,13 @@ namespace NzbDrone.Core.Test.UpdateTests Subject.GetLatestUpdate("master", new Version(2, 0)).Should().NotBeNull(); } + [Test] + public void should_get_master_if_branch_doesnt_exit() + { + UseRealHttp(); + Subject.GetLatestUpdate("master2", new Version(2, 0)).Should().NotBeNull(); + } + [Test] public void should_get_recent_updates() @@ -37,6 +44,7 @@ namespace NzbDrone.Core.Test.UpdateTests recent.Should().OnlyContain(c => c.ReleaseDate.Year == 2014); recent.Should().OnlyContain(c => c.Changes.New != null); recent.Should().OnlyContain(c => c.Changes.Fixed != null); + recent.Should().OnlyContain(c => c.Branch == branch); } } } diff --git a/src/NzbDrone.Core/Jobs/TaskManager.cs b/src/NzbDrone.Core/Jobs/TaskManager.cs index 99e600fa6..83d76ba81 100644 --- a/src/NzbDrone.Core/Jobs/TaskManager.cs +++ b/src/NzbDrone.Core/Jobs/TaskManager.cs @@ -57,7 +57,7 @@ namespace NzbDrone.Core.Jobs { new ScheduledTask{ Interval = 1, TypeName = typeof(TrackedCommandCleanupCommand).FullName}, new ScheduledTask{ Interval = 1, TypeName = typeof(CheckForFinishedDownloadCommand).FullName}, - new ScheduledTask{ Interval = 1*60, TypeName = typeof(ApplicationUpdateCommand).FullName}, + new ScheduledTask{ Interval = 6*60, TypeName = typeof(ApplicationUpdateCommand).FullName}, new ScheduledTask{ Interval = 1*60, TypeName = typeof(TrimLogCommand).FullName}, new ScheduledTask{ Interval = 3*60, TypeName = typeof(UpdateSceneMappingCommand).FullName}, new ScheduledTask{ Interval = 6*60, TypeName = typeof(CheckHealthCommand).FullName}, diff --git a/src/NzbDrone.Core/Update/UpdateCheckService.cs b/src/NzbDrone.Core/Update/UpdateCheckService.cs index 720580eb2..b0be673bb 100644 --- a/src/NzbDrone.Core/Update/UpdateCheckService.cs +++ b/src/NzbDrone.Core/Update/UpdateCheckService.cs @@ -1,4 +1,5 @@ -using NLog; +using System; +using NLog; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Core.Configuration; @@ -40,6 +41,21 @@ namespace NzbDrone.Core.Update { _logger.ProgressDebug("No update available."); } + else if (latestAvailable.Branch != _configFileProvider.Branch) + { + try + { + _logger.Warn("[{0}] isn't a valid branch. Switching back to [master]", _configFileProvider.Branch); + var config = _configFileProvider.GetConfigDictionary(); + config["Branch"] = _configFileProvider.Branch; + _configFileProvider.SaveConfigDictionary(config); + } + catch (Exception e) + { + _logger.ErrorException("couldn't revert back to master.", e); + } + + } return latestAvailable; } diff --git a/src/NzbDrone.Core/Update/UpdatePackage.cs b/src/NzbDrone.Core/Update/UpdatePackage.cs index 299abd3de..e2408d601 100644 --- a/src/NzbDrone.Core/Update/UpdatePackage.cs +++ b/src/NzbDrone.Core/Update/UpdatePackage.cs @@ -11,5 +11,6 @@ namespace NzbDrone.Core.Update public String Url { get; set; } public UpdateChanges Changes { get; set; } public String Hash { get; set; } + public String Branch { get; set; } } }