mirror of https://github.com/lidarr/Lidarr
Removed InstallUpdate, instead manually triggering ApplicationUpdate.
This commit is contained in:
parent
2f06cc6ffa
commit
071839fa86
|
@ -61,6 +61,10 @@ namespace NzbDrone.Core.Test.UpdateTests
|
||||||
Mocker.GetMock<IProcessProvider>().Setup(c => c.GetCurrentProcess()).Returns(new ProcessInfo { Id = 12 });
|
Mocker.GetMock<IProcessProvider>().Setup(c => c.GetCurrentProcess()).Returns(new ProcessInfo { Id = 12 });
|
||||||
Mocker.GetMock<IRuntimeInfo>().Setup(c => c.ExecutingApplication).Returns(@"C:\Test\NzbDrone.exe");
|
Mocker.GetMock<IRuntimeInfo>().Setup(c => c.ExecutingApplication).Returns(@"C:\Test\NzbDrone.exe");
|
||||||
|
|
||||||
|
Mocker.GetMock<IConfigFileProvider>()
|
||||||
|
.SetupGet(s => s.UpdateAutomatically)
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(c => c.FolderWritable(It.IsAny<string>()))
|
.Setup(c => c.FolderWritable(It.IsAny<string>()))
|
||||||
.Returns(true);
|
.Returns(true);
|
||||||
|
@ -289,7 +293,7 @@ namespace NzbDrone.Core.Test.UpdateTests
|
||||||
|
|
||||||
var updateArchive = Path.Combine(_sandboxFolder, _updatePackage.FileName);
|
var updateArchive = Path.Combine(_sandboxFolder, _updatePackage.FileName);
|
||||||
|
|
||||||
Subject.Execute(new InstallUpdateCommand() { UpdatePackage = _updatePackage });
|
Subject.Execute(new ApplicationUpdateCommand());
|
||||||
|
|
||||||
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(_updatePackage.Url, updateArchive), Times.Never());
|
Mocker.GetMock<IHttpClient>().Verify(c => c.DownloadFile(_updatePackage.Url, updateArchive), Times.Never());
|
||||||
ExceptionVerification.ExpectedErrors(1);
|
ExceptionVerification.ExpectedErrors(1);
|
||||||
|
@ -300,7 +304,7 @@ namespace NzbDrone.Core.Test.UpdateTests
|
||||||
{
|
{
|
||||||
_updatePackage.Branch = "fake";
|
_updatePackage.Branch = "fake";
|
||||||
|
|
||||||
Subject.Execute(new InstallUpdateCommand() { UpdatePackage = _updatePackage });
|
Subject.Execute(new ApplicationUpdateCommand());
|
||||||
|
|
||||||
Mocker.GetMock<IConfigFileProvider>()
|
Mocker.GetMock<IConfigFileProvider>()
|
||||||
.Verify(v => v.SaveConfigDictionary(It.Is<Dictionary<string, object>>(d => d.ContainsKey("Branch") && (string)d["Branch"] == "fake")), Times.Once());
|
.Verify(v => v.SaveConfigDictionary(It.Is<Dictionary<string, object>>(d => d.ContainsKey("Branch") && (string)d["Branch"] == "fake")), Times.Once());
|
||||||
|
|
|
@ -852,7 +852,6 @@
|
||||||
<Compile Include="Tv\SeriesTypes.cs" />
|
<Compile Include="Tv\SeriesTypes.cs" />
|
||||||
<Compile Include="Tv\ShouldRefreshSeries.cs" />
|
<Compile Include="Tv\ShouldRefreshSeries.cs" />
|
||||||
<Compile Include="Update\Commands\ApplicationUpdateCommand.cs" />
|
<Compile Include="Update\Commands\ApplicationUpdateCommand.cs" />
|
||||||
<Compile Include="Update\Commands\InstallUpdateCommand.cs" />
|
|
||||||
<Compile Include="Update\InstallUpdateService.cs" />
|
<Compile Include="Update\InstallUpdateService.cs" />
|
||||||
<Compile Include="Update\RecentUpdateProvider.cs" />
|
<Compile Include="Update\RecentUpdateProvider.cs" />
|
||||||
<Compile Include="Update\UpdateAbortedException.cs" />
|
<Compile Include="Update\UpdateAbortedException.cs" />
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
|
||||||
|
|
||||||
namespace NzbDrone.Core.Update.Commands
|
|
||||||
{
|
|
||||||
public class InstallUpdateCommand : Command
|
|
||||||
{
|
|
||||||
public UpdatePackage UpdatePackage { get; set; }
|
|
||||||
|
|
||||||
public override bool SendUpdatesToClient
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,7 +17,7 @@ using NzbDrone.Core.Update.Commands;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Update
|
namespace NzbDrone.Core.Update
|
||||||
{
|
{
|
||||||
public class InstallUpdateService : IExecute<ApplicationUpdateCommand>, IExecute<InstallUpdateCommand>
|
public class InstallUpdateService : IExecute<ApplicationUpdateCommand>
|
||||||
{
|
{
|
||||||
private readonly ICheckUpdateService _checkUpdateService;
|
private readonly ICheckUpdateService _checkUpdateService;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
@ -176,15 +176,31 @@ namespace NzbDrone.Core.Update
|
||||||
if (_appFolderInfo.StartUpFolder.IsParentPath(_appFolderInfo.AppDataFolder) ||
|
if (_appFolderInfo.StartUpFolder.IsParentPath(_appFolderInfo.AppDataFolder) ||
|
||||||
_appFolderInfo.StartUpFolder.PathEquals(_appFolderInfo.AppDataFolder))
|
_appFolderInfo.StartUpFolder.PathEquals(_appFolderInfo.AppDataFolder))
|
||||||
{
|
{
|
||||||
throw new UpdateFailedException("You Sonarr configuration ('{0}') is being stored in application folder ('{1}') which will cause data lost during the upgrade. Please remove any symlinks or redirects before trying again.", _appFolderInfo.AppDataFolder, _appFolderInfo.StartUpFolder);
|
throw new UpdateFailedException("Your Sonarr configuration '{0}' is being stored in application folder '{1}' which will cause data lost during the upgrade. Please remove any symlinks or redirects before trying again.", _appFolderInfo.AppDataFolder, _appFolderInfo.StartUpFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteInstallUpdate(Command message, UpdatePackage package)
|
public void Execute(ApplicationUpdateCommand message)
|
||||||
{
|
{
|
||||||
|
_logger.ProgressDebug("Checking for updates");
|
||||||
|
|
||||||
|
var latestAvailable = _checkUpdateService.AvailableUpdate();
|
||||||
|
|
||||||
|
if (latestAvailable == null)
|
||||||
|
{
|
||||||
|
_logger.ProgressDebug("No update available.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OsInfo.IsNotWindows && !_configFileProvider.UpdateAutomatically && !message.Manual)
|
||||||
|
{
|
||||||
|
_logger.ProgressDebug("Auto-update not enabled, not installing available update.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InstallUpdate(package);
|
InstallUpdate(latestAvailable);
|
||||||
|
|
||||||
message.Completed("Restarting Sonarr to apply updates");
|
message.Completed("Restarting Sonarr to apply updates");
|
||||||
}
|
}
|
||||||
|
@ -204,28 +220,5 @@ namespace NzbDrone.Core.Update
|
||||||
message.Failed(ex);
|
message.Failed(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(ApplicationUpdateCommand message)
|
|
||||||
{
|
|
||||||
_logger.ProgressDebug("Checking for updates");
|
|
||||||
var latestAvailable = _checkUpdateService.AvailableUpdate();
|
|
||||||
|
|
||||||
if (latestAvailable != null)
|
|
||||||
{
|
|
||||||
ExecuteInstallUpdate(message, latestAvailable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Execute(InstallUpdateCommand message)
|
|
||||||
{
|
|
||||||
var latestAvailable = _checkUpdateService.AvailableUpdate();
|
|
||||||
|
|
||||||
if (latestAvailable == null || latestAvailable.Hash != message.UpdatePackage.Hash)
|
|
||||||
{
|
|
||||||
throw new ApplicationException("Unknown or invalid update specified");
|
|
||||||
}
|
|
||||||
|
|
||||||
ExecuteInstallUpdate(message, latestAvailable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,19 +31,7 @@ namespace NzbDrone.Core.Update
|
||||||
|
|
||||||
public UpdatePackage AvailableUpdate()
|
public UpdatePackage AvailableUpdate()
|
||||||
{
|
{
|
||||||
var latestAvailable = _updatePackageProvider.GetLatestUpdate(_configFileProvider.Branch, BuildInfo.Version);
|
return _updatePackageProvider.GetLatestUpdate(_configFileProvider.Branch, BuildInfo.Version);
|
||||||
|
|
||||||
if (OsInfo.IsNotWindows && !_configFileProvider.UpdateAutomatically)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (latestAvailable == null)
|
|
||||||
{
|
|
||||||
_logger.ProgressDebug("No update available.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return latestAvailable;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,7 +13,7 @@ module.exports = Marionette.ItemView.extend({
|
||||||
}
|
}
|
||||||
this.updating = true;
|
this.updating = true;
|
||||||
var self = this;
|
var self = this;
|
||||||
var promise = CommandController.Execute('installUpdate', {updatePackage : this.model.toJSON()});
|
var promise = CommandController.Execute('applicationUpdate');
|
||||||
promise.done(function(){
|
promise.done(function(){
|
||||||
window.setTimeout(function(){
|
window.setTimeout(function(){
|
||||||
self.updating = false;
|
self.updating = false;
|
||||||
|
|
|
@ -5,14 +5,17 @@
|
||||||
- {{ShortDate releaseDate}}
|
- {{ShortDate releaseDate}}
|
||||||
</span>
|
</span>
|
||||||
<span class="status">
|
<span class="status">
|
||||||
|
{{#unless_eq branch compare="master"}}
|
||||||
|
<span class="label label-default">{{branch}}</span>
|
||||||
|
{{/unless_eq}}
|
||||||
{{#if installed}}
|
{{#if installed}}
|
||||||
<span class="label label-success">Installed</span>
|
<span class="label label-success">Installed</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if latest}}
|
{{#if latest}}
|
||||||
{{#if installable}}
|
{{#if installable}}
|
||||||
<span class="label label-default install-update x-install-update">Install</span>
|
<span class="label label-info install-update x-install-update">Install Latest</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span class="label label-default label-disabled" title="Cannot install an older version">Install</span>
|
<span class="label label-info label-disabled" title="Cannot install an older version">Install Latest</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
Loading…
Reference in New Issue