Fixed: Branch redirects will now occur during install of the a new update instead of during an update check.

This commit is contained in:
Taloth Saldono 2015-01-25 22:21:17 +01:00
commit 2f06cc6ffa
3 changed files with 33 additions and 15 deletions

View file

@ -102,6 +102,8 @@ namespace NzbDrone.Core.Update
_archiveService.Extract(packageDestination, updateSandboxFolder);
_logger.Info("Update package extracted successfully");
EnsureValidBranch(updatePackage);
_backupService.Backup(BackupType.Update);
if (OsInfo.IsNotWindows && _configFileProvider.UpdateMechanism == UpdateMechanism.Script)
@ -120,6 +122,25 @@ namespace NzbDrone.Core.Update
_processProvider.Start(_appFolderInfo.GetUpdateClientExePath(), GetUpdaterArgs(updateSandboxFolder));
}
private void EnsureValidBranch(UpdatePackage package)
{
var currentBranch = _configFileProvider.Branch;
if (package.Branch != currentBranch)
{
try
{
_logger.Info("Branch [{0}] is being redirected to [{1}]]", currentBranch, package.Branch);
var config = new Dictionary<string, object>();
config["Branch"] = package.Branch;
_configFileProvider.SaveConfigDictionary(config);
}
catch (Exception e)
{
_logger.ErrorException(string.Format("Couldn't change the branch from [{0}] to [{1}].", currentBranch, package.Branch), e);
}
}
}
private void InstallUpdateWithScript(String updateSandboxFolder)
{
var scriptPath = _configFileProvider.UpdateScriptPath;