1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-18 23:48:35 +02:00
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-07 01:22:43 +03:00
using NzbDrone.Common.EnvironmentInfo;
2013-05-20 03:30:02 +03:00
using NzbDrone.Core.Update;
using NzbDrone.Api.Mapping;
namespace NzbDrone.Api.Update
{
public class UpdateModule : NzbDroneRestModule<UpdateResource>
{
private readonly IRecentUpdateProvider _recentUpdateProvider;
2013-05-20 03:30:02 +03:00
2014-09-12 02:49:41 +03:00
public UpdateModule(IRecentUpdateProvider recentUpdateProvider)
2013-05-20 03:30:02 +03:00
{
_recentUpdateProvider = recentUpdateProvider;
GetResourceAll = GetRecentUpdates;
2013-05-20 03:30:02 +03:00
}
private List<UpdateResource> GetRecentUpdates()
2013-05-20 03:30:02 +03:00
{
var resources = _recentUpdateProvider.GetRecentUpdatePackages()
.OrderByDescending(u => u.Version)
.InjectTo<List<UpdateResource>>();
2013-05-20 03:30:02 +03:00
2013-10-07 01:22:43 +03:00
foreach (var updateResource in resources)
2013-05-20 03:30:02 +03:00
{
2013-10-07 01:22:43 +03:00
if (updateResource.Version > BuildInfo.Version)
{
updateResource.IsUpgrade = true;
}
else if (updateResource.Version == BuildInfo.Version)
{
updateResource.Installed = true;
}
2013-05-20 03:30:02 +03:00
}
return resources;
2013-05-20 03:30:02 +03:00
}
}
}