New: Allow major version updates to be installed (#2260)

* New: Allow major version updates to be installed

(cherry picked from commit 0e95ba2021b23cc65bce0a0620dd48e355250dab)

* fixup! New: Allow major version updates to be installed

---------

Co-authored-by: Mark McDowall <mark@mcdowall.ca>
This commit is contained in:
Bogdan
2024-10-19 09:01:23 +03:00
committed by GitHub
parent 9037cde439
commit 8aad1ac554
16 changed files with 425 additions and 417 deletions

View File

@@ -35,18 +35,18 @@ namespace NzbDrone.Core.Test.UpdateTests
{
_updatePackage = new UpdatePackage
{
FileName = "NzbDrone.develop.2.0.0.0.tar.gz",
FileName = "NzbDrone.develop.1.0.0.0.tar.gz",
Url = "http://download.sonarr.tv/v2/develop/mono/NzbDrone.develop.tar.gz",
Version = new Version("2.0.0.0")
Version = new Version("1.0.0.0")
};
}
else
{
_updatePackage = new UpdatePackage
{
FileName = "NzbDrone.develop.2.0.0.0.zip",
FileName = "NzbDrone.develop.1.0.0.0.zip",
Url = "http://download.sonarr.tv/v2/develop/windows/NzbDrone.develop.zip",
Version = new Version("2.0.0.0")
Version = new Version("1.0.0.0")
};
}

View File

@@ -445,6 +445,11 @@
"Info": "Info",
"InfoUrl": "Info URL",
"InitialFailure": "Initial Failure",
"Install": "Install",
"InstallLatest": "Install Latest",
"InstallMajorVersionUpdate": "Install Update",
"InstallMajorVersionUpdateMessage": "This update will install a new major version and may not be compatible with your system. Are you sure you want to install this update?",
"InstallMajorVersionUpdateMessageLink": "Please check [{domain}]({url}) for more information.",
"InstanceName": "Instance Name",
"InstanceNameHelpText": "Instance name in tab and for Syslog app name",
"InteractiveSearch": "Interactive Search",

View File

@@ -7,5 +7,7 @@ namespace NzbDrone.Core.Update.Commands
public override bool SendUpdatesToClient => true;
public override string CompletionMessage => null;
public bool InstallMajorUpdate { get; set; }
}
}

View File

@@ -4,6 +4,7 @@ namespace NzbDrone.Core.Update.Commands
{
public class ApplicationUpdateCommand : Command
{
public bool InstallMajorUpdate { get; set; }
public override bool SendUpdatesToClient => true;
public override bool IsExclusive => true;
}

View File

@@ -231,7 +231,7 @@ namespace NzbDrone.Core.Update
}
}
private UpdatePackage GetUpdatePackage(CommandTrigger updateTrigger)
private UpdatePackage GetUpdatePackage(CommandTrigger updateTrigger, bool installMajorUpdate)
{
_logger.ProgressDebug("Checking for updates");
@@ -243,7 +243,13 @@ namespace NzbDrone.Core.Update
return null;
}
if (OsInfo.IsNotWindows && !_configFileProvider.UpdateAutomatically && updateTrigger != CommandTrigger.Manual)
if (latestAvailable.Version.Major > BuildInfo.Version.Major && !installMajorUpdate)
{
_logger.ProgressInfo("Unable to install major update, please update update manually from System: Updates");
return null;
}
if (!_configFileProvider.UpdateAutomatically && updateTrigger != CommandTrigger.Manual)
{
_logger.ProgressDebug("Auto-update not enabled, not installing available update.");
return null;
@@ -272,7 +278,7 @@ namespace NzbDrone.Core.Update
public void Execute(ApplicationUpdateCheckCommand message)
{
if (GetUpdatePackage(message.Trigger) != null)
if (GetUpdatePackage(message.Trigger, true) != null)
{
_commandQueueManager.Push(new ApplicationUpdateCommand(), trigger: message.Trigger);
}
@@ -280,7 +286,7 @@ namespace NzbDrone.Core.Update
public void Execute(ApplicationUpdateCommand message)
{
var latestAvailable = GetUpdatePackage(message.Trigger);
var latestAvailable = GetUpdatePackage(message.Trigger, message.InstallMajorUpdate);
if (latestAvailable != null)
{

View File

@@ -47,6 +47,7 @@ namespace NzbDrone.Core.Update
.AddQueryParam("runtime", "netcore")
.AddQueryParam("runtimeVer", _platformInfo.Version)
.AddQueryParam("dbType", _mainDatabase.DatabaseType)
.AddQueryParam("includeMajorVersion", true)
.SetSegment("branch", branch);
if (_analyticsService.IsEnabled)