New: automatically switch back to master if current branch is invalid

This commit is contained in:
Keivan Beigi 2014-10-28 16:48:37 -07:00
parent 95d67ef9f4
commit aa68faaf88
4 changed files with 27 additions and 2 deletions

View file

@ -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;
}