From 524048c4b4df07790b107edf3a03be3e727ed800 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Mon, 26 Nov 2018 21:50:09 +0100 Subject: [PATCH] Also force branch if an external updater is used. --- .../Update/ConfigureUpdateMechanism.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/NzbDrone.Core/Update/ConfigureUpdateMechanism.cs b/src/NzbDrone.Core/Update/ConfigureUpdateMechanism.cs index c8592166d..e67b79c84 100644 --- a/src/NzbDrone.Core/Update/ConfigureUpdateMechanism.cs +++ b/src/NzbDrone.Core/Update/ConfigureUpdateMechanism.cs @@ -1,4 +1,5 @@ using NLog; +using NzbDrone.Common.Extensions; using NzbDrone.Core.Configuration; using NzbDrone.Core.Lifecycle; using NzbDrone.Core.Messaging.Events; @@ -48,6 +49,17 @@ namespace NzbDrone.Core.Update break; } } + + if (_deploymentInfoProvider.IsExternalUpdateMechanism) + { + var currentBranch = _configFileProvider.Branch; + var packageBranch = _deploymentInfoProvider.PackageBranch; + if (packageBranch.IsNotNullOrWhiteSpace() & packageBranch != currentBranch) + { + _logger.Info("External updater uses branch {0} instead of the currently selected {1}, changing to {0}.", packageBranch, currentBranch); + ChangeBranch(packageBranch); + } + } } private void ChangeUpdateMechanism(UpdateMechanism updateMechanism) @@ -58,5 +70,14 @@ namespace NzbDrone.Core.Update }; _configFileProvider.SaveConfigDictionary(config); } + + private void ChangeBranch(string branch) + { + var config = new Dictionary + { + [nameof(_configFileProvider.Branch)] = branch + }; + _configFileProvider.SaveConfigDictionary(config); + } } }