2013-06-28 03:04:52 +03:00
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2013-09-11 09:33:47 +03:00
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
using NzbDrone.Core.Instrumentation;
|
2013-06-28 03:04:52 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Update
|
|
|
|
{
|
|
|
|
public interface ICheckUpdateService
|
|
|
|
{
|
|
|
|
UpdatePackage AvailableUpdate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class CheckUpdateService : ICheckUpdateService
|
|
|
|
{
|
|
|
|
private readonly IUpdatePackageProvider _updatePackageProvider;
|
2013-09-11 09:33:47 +03:00
|
|
|
private readonly IConfigFileProvider _configFileProvider;
|
2013-06-28 03:04:52 +03:00
|
|
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
2013-09-11 09:33:47 +03:00
|
|
|
public CheckUpdateService(IUpdatePackageProvider updatePackageProvider, IConfigFileProvider configFileProvider, Logger logger)
|
2013-06-28 03:04:52 +03:00
|
|
|
{
|
|
|
|
_updatePackageProvider = updatePackageProvider;
|
2013-09-11 09:33:47 +03:00
|
|
|
_configFileProvider = configFileProvider;
|
2013-06-28 03:04:52 +03:00
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
public UpdatePackage AvailableUpdate()
|
|
|
|
{
|
2013-09-11 09:33:47 +03:00
|
|
|
var latestAvailable = _updatePackageProvider.GetLatestUpdate(_configFileProvider.Branch, BuildInfo.Version);
|
2013-06-28 03:04:52 +03:00
|
|
|
|
2013-08-24 05:21:12 +03:00
|
|
|
if (latestAvailable == null)
|
2013-06-28 03:04:52 +03:00
|
|
|
{
|
2013-09-11 09:33:47 +03:00
|
|
|
_logger.ProgressDebug("No update available.");
|
2013-06-28 03:04:52 +03:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return latestAvailable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|