mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
fixed apptype detection during update
This commit is contained in:
parent
2573558321
commit
99f269cd95
11 changed files with 300 additions and 187 deletions
38
NzbDrone.Update/UpdateEngine/DetectApplicationType.cs
Normal file
38
NzbDrone.Update/UpdateEngine/DetectApplicationType.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System.Linq;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Update.UpdateEngine
|
||||
{
|
||||
public interface IDetectApplicationType
|
||||
{
|
||||
AppType GetAppType();
|
||||
}
|
||||
|
||||
public class DetectApplicationType : IDetectApplicationType
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly IProcessProvider _processProvider;
|
||||
|
||||
public DetectApplicationType(IServiceProvider serviceProvider, IProcessProvider processProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
_processProvider = processProvider;
|
||||
}
|
||||
|
||||
public AppType GetAppType()
|
||||
{
|
||||
if (_serviceProvider.ServiceExist(ServiceProvider.NZBDRONE_SERVICE_NAME)
|
||||
&& _serviceProvider.IsServiceRunning(ServiceProvider.NZBDRONE_SERVICE_NAME))
|
||||
{
|
||||
return AppType.Service;
|
||||
}
|
||||
|
||||
if (_processProvider.GetProcessByName(ProcessProvider.NzbDroneConsoleProcessName).Any())
|
||||
{
|
||||
return AppType.Console;
|
||||
}
|
||||
|
||||
return AppType.Normal;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue