mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 19:40:05 -07:00
Potentially fix the user profiles issue
This commit is contained in:
parent
35070b1427
commit
12d37511ee
2 changed files with 15 additions and 20 deletions
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
|
||||||
using Ombi.Api.Radarr;
|
using Ombi.Api.Radarr;
|
||||||
using Ombi.Api.Radarr.Models;
|
using Ombi.Api.Radarr.Models;
|
||||||
using Ombi.Attributes;
|
using Ombi.Attributes;
|
||||||
|
@ -13,9 +12,9 @@ using Ombi.Settings.Settings.Models.External;
|
||||||
|
|
||||||
namespace Ombi.Controllers.External
|
namespace Ombi.Controllers.External
|
||||||
{
|
{
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ApiV1]
|
[ApiV1]
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
public class RadarrController : Controller
|
public class RadarrController : Controller
|
||||||
{
|
{
|
||||||
public RadarrController(IRadarrApi radarr, ISettingsService<RadarrSettings> settings,
|
public RadarrController(IRadarrApi radarr, ISettingsService<RadarrSettings> settings,
|
||||||
|
@ -24,6 +23,7 @@ namespace Ombi.Controllers.External
|
||||||
RadarrApi = radarr;
|
RadarrApi = radarr;
|
||||||
RadarrSettings = settings;
|
RadarrSettings = settings;
|
||||||
Cache = mem;
|
Cache = mem;
|
||||||
|
RadarrSettings.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IRadarrApi RadarrApi { get; }
|
private IRadarrApi RadarrApi { get; }
|
||||||
|
@ -61,15 +61,12 @@ namespace Ombi.Controllers.External
|
||||||
[HttpGet("Profiles")]
|
[HttpGet("Profiles")]
|
||||||
public async Task<IEnumerable<RadarrProfile>> GetProfiles()
|
public async Task<IEnumerable<RadarrProfile>> GetProfiles()
|
||||||
{
|
{
|
||||||
return await Cache.GetOrAdd(CacheKeys.RadarrQualityProfiles, async () =>
|
var settings = await RadarrSettings.GetSettingsAsync();
|
||||||
|
if (settings.Enabled)
|
||||||
{
|
{
|
||||||
var settings = await RadarrSettings.GetSettingsAsync();
|
return await RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
|
||||||
if (settings.Enabled)
|
}
|
||||||
{
|
return null;
|
||||||
return await RadarrApi.GetProfiles(settings.ApiKey, settings.FullUri);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}, DateTime.Now.AddHours(1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -80,15 +77,12 @@ namespace Ombi.Controllers.External
|
||||||
[HttpGet("RootFolders")]
|
[HttpGet("RootFolders")]
|
||||||
public async Task<IEnumerable<RadarrRootFolder>> GetRootFolders()
|
public async Task<IEnumerable<RadarrRootFolder>> GetRootFolders()
|
||||||
{
|
{
|
||||||
return await Cache.GetOrAdd(CacheKeys.RadarrRootProfiles, async () =>
|
var settings = await RadarrSettings.GetSettingsAsync();
|
||||||
|
if (settings.Enabled)
|
||||||
{
|
{
|
||||||
var settings = await RadarrSettings.GetSettingsAsync();
|
return await RadarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
|
||||||
if (settings.Enabled)
|
}
|
||||||
{
|
return null;
|
||||||
return await RadarrApi.GetRootFolders(settings.ApiKey, settings.FullUri);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}, DateTime.Now.AddHours(1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@ namespace Ombi.Controllers.External
|
||||||
{
|
{
|
||||||
SonarrApi = sonarr;
|
SonarrApi = sonarr;
|
||||||
SonarrSettings = settings;
|
SonarrSettings = settings;
|
||||||
|
SonarrSettings.ClearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISonarrApi SonarrApi { get; }
|
private ISonarrApi SonarrApi { get; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue