mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-30 19:56:54 +00:00
42 lines
No EOL
1.2 KiB
C#
42 lines
No EOL
1.2 KiB
C#
using NLog;
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
using NzbDrone.Core.Configuration;
|
|
using NzbDrone.Core.Instrumentation;
|
|
|
|
namespace NzbDrone.Core.Update
|
|
{
|
|
public interface ICheckUpdateService
|
|
{
|
|
UpdatePackage AvailableUpdate();
|
|
}
|
|
|
|
|
|
public class CheckUpdateService : ICheckUpdateService
|
|
{
|
|
private readonly IUpdatePackageProvider _updatePackageProvider;
|
|
private readonly IConfigFileProvider _configFileProvider;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
public CheckUpdateService(IUpdatePackageProvider updatePackageProvider, IConfigFileProvider configFileProvider, Logger logger)
|
|
{
|
|
_updatePackageProvider = updatePackageProvider;
|
|
_configFileProvider = configFileProvider;
|
|
_logger = logger;
|
|
}
|
|
|
|
public UpdatePackage AvailableUpdate()
|
|
{
|
|
var latestAvailable = _updatePackageProvider.GetLatestUpdate(_configFileProvider.Branch, BuildInfo.Version);
|
|
|
|
if (latestAvailable == null)
|
|
{
|
|
_logger.ProgressDebug("No update available.");
|
|
return null;
|
|
}
|
|
|
|
return latestAvailable;
|
|
}
|
|
}
|
|
} |