mirror of https://github.com/Radarr/Radarr
Fixed: Branch redirects will now occur during install of the a new update instead of during an update check.
This commit is contained in:
parent
7ce9f416d1
commit
2f06cc6ffa
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
|
@ -294,6 +295,17 @@ namespace NzbDrone.Core.Test.UpdateTests
|
|||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_switch_to_branch_specified_in_updatepackage()
|
||||
{
|
||||
_updatePackage.Branch = "fake";
|
||||
|
||||
Subject.Execute(new InstallUpdateCommand() { UpdatePackage = _updatePackage });
|
||||
|
||||
Mocker.GetMock<IConfigFileProvider>()
|
||||
.Verify(v => v.SaveConfigDictionary(It.Is<Dictionary<string, object>>(d => d.ContainsKey("Branch") && (string)d["Branch"] == "fake")), Times.Once());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -42,21 +42,6 @@ namespace NzbDrone.Core.Update
|
|||
{
|
||||
_logger.ProgressDebug("No update available.");
|
||||
}
|
||||
else if (latestAvailable.Branch != _configFileProvider.Branch)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.Info("Branch [{0}] is being redirected to [{1}]]", _configFileProvider.Branch, latestAvailable.Branch);
|
||||
var config = new Dictionary<string, object>();
|
||||
config["Branch"] = latestAvailable.Branch;
|
||||
_configFileProvider.SaveConfigDictionary(config);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorException("Couldn't save the branch redirect.", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return latestAvailable;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue