mirror of
https://github.com/lidarr/Lidarr
synced 2025-03-03 18:15:37 +00:00
Fixed: Fixed an issue where there could be a race condition during app update.
This commit is contained in:
parent
aa42111516
commit
39be4c567d
3 changed files with 16 additions and 7 deletions
|
@ -57,6 +57,12 @@ public virtual Process Start(ProcessStartInfo startInfo)
|
||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void WaitForExit(Process process)
|
||||||
|
{
|
||||||
|
Logger.Trace("Waiting for process {0} to exit.", process.ProcessName);
|
||||||
|
process.WaitForExit();
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void Kill(int processId)
|
public virtual void Kill(int processId)
|
||||||
{
|
{
|
||||||
if (processId == 0 || !Process.GetProcesses().Any(p => p.Id == processId))
|
if (processId == 0 || !Process.GetProcesses().Any(p => p.Id == processId))
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using FizzWare.NBuilder;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
@ -62,7 +63,7 @@ public void should_not_delete_sandbox_before_update_if_folder_doesnt_exists()
|
||||||
Mocker.GetMock<DiskProvider>().Verify(c => c.DeleteFolder(SANDBOX_FOLDER, true), Times.Never());
|
Mocker.GetMock<DiskProvider>().Verify(c => c.DeleteFolder(SANDBOX_FOLDER, true), Times.Never());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Should_download_update_package()
|
public void Should_download_update_package()
|
||||||
{
|
{
|
||||||
|
@ -126,7 +127,7 @@ public void should_start_update_client()
|
||||||
public void when_no_updates_are_available_should_return_without_error_or_warnings()
|
public void when_no_updates_are_available_should_return_without_error_or_warnings()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<UpdateProvider>().Setup(c => c.GetAvilableUpdate(It.IsAny<Version>())).Returns((UpdatePackage)null);
|
Mocker.GetMock<UpdateProvider>().Setup(c => c.GetAvilableUpdate(It.IsAny<Version>())).Returns((UpdatePackage)null);
|
||||||
|
|
||||||
StartUpdate();
|
StartUpdate();
|
||||||
|
|
||||||
ExceptionVerification.AssertNoUnexcpectedLogs();
|
ExceptionVerification.AssertNoUnexcpectedLogs();
|
||||||
|
|
|
@ -47,7 +47,7 @@ public TimeSpan DefaultInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
||||||
{
|
{
|
||||||
notification.CurrentMessage = "Checking for updates";
|
notification.CurrentMessage = "Checking for updates";
|
||||||
|
|
||||||
var updatePackage = _updateProvider.GetAvilableUpdate(_enviromentProvider.Version);
|
var updatePackage = _updateProvider.GetAvilableUpdate(_enviromentProvider.Version);
|
||||||
|
@ -82,12 +82,14 @@ public virtual void Start(ProgressNotification notification, int targetId, int s
|
||||||
logger.Info("Starting update client");
|
logger.Info("Starting update client");
|
||||||
var startInfo = new ProcessStartInfo
|
var startInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = _enviromentProvider.GetUpdateClientExePath(),
|
FileName = _enviromentProvider.GetUpdateClientExePath(),
|
||||||
Arguments = string.Format("{0} {1}", _enviromentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid)
|
Arguments = string.Format("{0} {1}", _enviromentProvider.NzbDroneProcessIdFromEnviroment, _configFileProvider.Guid)
|
||||||
};
|
};
|
||||||
|
|
||||||
_processProvider.Start(startInfo);
|
var process = _processProvider.Start(startInfo);
|
||||||
notification.CurrentMessage = "Update in progress. NzbDrone will restart shortly.";
|
notification.CurrentMessage = "Update in progress. NzbDrone will restart shortly.";
|
||||||
|
|
||||||
|
_processProvider.WaitForExit(process);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue