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

41 lines
1.3 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;
2013-05-19 17:30:02 -07:00
2014-09-11 16:49:41 -07:00
public UpdateModule(IRecentUpdateProvider recentUpdateProvider)
2013-05-19 17:30:02 -07:00
{
_recentUpdateProvider = recentUpdateProvider;
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
}
}
}