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