You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
3 years ago
|
using System.Collections.Generic;
|
||
7 years ago
|
using System.Linq;
|
||
5 years ago
|
using Lidarr.Http;
|
||
3 years ago
|
using Microsoft.AspNetCore.Mvc;
|
||
7 years ago
|
using NzbDrone.Common.EnvironmentInfo;
|
||
|
using NzbDrone.Core.Update;
|
||
|
|
||
7 years ago
|
namespace Lidarr.Api.V1.Update
|
||
7 years ago
|
{
|
||
3 years ago
|
[V1ApiController]
|
||
|
public class UpdateController : Controller
|
||
7 years ago
|
{
|
||
|
private readonly IRecentUpdateProvider _recentUpdateProvider;
|
||
|
|
||
3 years ago
|
public UpdateController(IRecentUpdateProvider recentUpdateProvider)
|
||
7 years ago
|
{
|
||
|
_recentUpdateProvider = recentUpdateProvider;
|
||
|
}
|
||
|
|
||
3 years ago
|
[HttpGet]
|
||
|
public List<UpdateResource> GetRecentUpdates()
|
||
7 years ago
|
{
|
||
|
var resources = _recentUpdateProvider.GetRecentUpdatePackages()
|
||
|
.OrderByDescending(u => u.Version)
|
||
|
.ToResource();
|
||
|
|
||
|
if (resources.Any())
|
||
|
{
|
||
|
var first = resources.First();
|
||
|
first.Latest = true;
|
||
|
|
||
|
if (first.Version > BuildInfo.Version)
|
||
|
{
|
||
|
first.Installable = true;
|
||
|
}
|
||
|
|
||
|
var installed = resources.SingleOrDefault(r => r.Version == BuildInfo.Version);
|
||
|
|
||
|
if (installed != null)
|
||
|
{
|
||
|
installed.Installed = true;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return resources;
|
||
|
}
|
||
|
}
|
||
5 years ago
|
}
|