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); + } } }