1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-03-07 15:20:58 +02:00
Sonarr/src/NzbDrone.Api/Update/UpdateModule.cs

44 lines
1.4 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.Linq;
2013-10-06 15:22:43 -07:00
using NzbDrone.Common.EnvironmentInfo;
2013-05-19 17:30:02 -07:00
using NzbDrone.Core.Update;
using NzbDrone.Api.Mapping;
namespace NzbDrone.Api.Update
{
public class UpdateModule : NzbDroneRestModule<UpdateResource>
{
private readonly IRecentUpdateProvider _recentUpdateProvider;
private readonly IInstallUpdates _installUpdateService;
2013-05-19 17:30:02 -07:00
public UpdateModule(IRecentUpdateProvider recentUpdateProvider,
IInstallUpdates installUpdateService)
2013-05-19 17:30:02 -07:00
{
_recentUpdateProvider = recentUpdateProvider;
_installUpdateService = installUpdateService;
GetResourceAll = GetRecentUpdates;
2013-05-19 17:30:02 -07:00
}
private List<UpdateResource> GetRecentUpdates()
2013-05-19 17:30:02 -07:00
{
var resources = _recentUpdateProvider.GetRecentUpdatePackages()
.OrderByDescending(u => u.Version)
.InjectTo<List<UpdateResource>>();
2013-05-19 17:30:02 -07:00
2013-10-06 15:22:43 -07:00
foreach (var updateResource in resources)
2013-05-19 17:30:02 -07:00
{
2013-10-06 15:22:43 -07:00
if (updateResource.Version > BuildInfo.Version)
{
updateResource.IsUpgrade = true;
}
else if (updateResource.Version == BuildInfo.Version)
{
updateResource.Installed = true;
}
2013-05-19 17:30:02 -07:00
}
return resources;
2013-05-19 17:30:02 -07:00
}
}
}