Skip to content

Commit

Permalink
clean out manual precondition checks
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Apr 15, 2024
1 parent 02a842f commit 30838ee
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 38 deletions.
3 changes: 0 additions & 3 deletions XLWebServices/Controllers/Dalamud/AssetController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ public AssetController(FallibleService<AssetCacheService> assetCache, IConfigura
[HttpGet]
public IActionResult Meta()
{
if (this.assetCache.HasFailed && this.assetCache.Get()?.Response == null)
return StatusCode(500, "Precondition failed");

return new JsonResult(this.assetCache.Get()!.Response);
}

Expand Down
14 changes: 1 addition & 13 deletions XLWebServices/Controllers/Dalamud/ReleaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public ReleaseController(FallibleService<DalamudReleaseDataService> releaseCache
[HttpGet]
public IActionResult VersionInfo([FromQuery] string? track = "", [FromQuery] string? appId = "", [FromQuery] string? bucket = "Control")
{
if (this.releaseCache.HasFailed && this.releaseCache.Get()?.DalamudVersions == null)
return StatusCode(500, "Precondition failed");

if (string.IsNullOrEmpty(track))
track = "release";

Expand Down Expand Up @@ -80,27 +77,18 @@ public IActionResult VersionInfo([FromQuery] string? track = "", [FromQuery] str
[HttpGet]
public IActionResult Meta()
{
if (this.releaseCache.HasFailed && this.releaseCache.Get()?.DalamudVersions == null)
return StatusCode(500, "Precondition failed");

return new JsonResult(this.releaseCache.Get()!.DalamudVersions);
}

[HttpGet]
public IActionResult Changelog()
{
if (this.releaseCache.HasFailed)
return StatusCode(500, "Precondition failed");

return new JsonResult(this.releaseCache.Get()!.DalamudChangelogs);
}

[HttpGet("{kind}/{version}")]
public async Task<IActionResult> Runtime(string version, string kind)
{
if (this.releaseCache.HasFailed && this.releaseCache.Get()?.DalamudVersions == null)
return StatusCode(500, "Precondition failed");

if (this.releaseCache.Get()!.DalamudVersions.All(x => x.Value.RuntimeVersion != version) && version != "5.0.6")
return this.BadRequest("Invalid version");

Expand Down Expand Up @@ -154,7 +142,7 @@ public async Task<IActionResult> ClearCache([FromQuery] string key)

private async ValueTask BuildClearCacheWorkItemAsync(CancellationToken token, IServiceProvider _)
{
_logger.LogInformation("Queued plogon commit is starting");
_logger.LogInformation("Queued Dalamud release refresh is starting");
var stopwatch = new Stopwatch();
stopwatch.Start();

Expand Down
3 changes: 0 additions & 3 deletions XLWebServices/Controllers/GitHubProxyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public GitHubProxyController(ILogger<GitHubProxyController> logger, IConfigurati
[HttpGet("{track:alpha}/{file}")]
public async Task<IActionResult> Update(string file, string track, string? localVersion = null)
{
if (_launcherReleaseData.HasFailed && this._launcherReleaseData.Get()?.CachedReleasesList == null)
return StatusCode(500, "Precondition failed");

if (_isCanaryEnabled)
{
if (Request.Headers.TryGetValue("cf-ray", out var ray))
Expand Down
18 changes: 0 additions & 18 deletions XLWebServices/Controllers/PluginController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ public async Task<IActionResult> Download(string internalName,
[FromQuery(Name = "isUpdate")] bool isUpdate = false,
[FromQuery(Name = "isDip17")] bool isDip17 = false)
{
if (this.pluginData.HasFailed&& this.pluginData.Get()?.PluginMaster == null)
return StatusCode(500, "Precondition failed");

var masterList = this.pluginData.Get()!.PluginMaster;

var manifest = masterList!.FirstOrDefault(x => x.InternalName == internalName);
Expand Down Expand Up @@ -84,9 +81,6 @@ public async Task<IActionResult> Download(string internalName,
[HttpGet]
public async Task<IActionResult> DownloadCounts()
{
if (this.pluginData.HasFailed || this.redis.HasFailed)
return StatusCode(500, "Precondition failed");

var counts = new Dictionary<string, long>();
foreach (var plugin in this.pluginData.Get()!.PluginMaster!)
{
Expand All @@ -99,9 +93,6 @@ public async Task<IActionResult> DownloadCounts()
[HttpGet]
public IActionResult PluginMaster([FromQuery] bool proxy = true, [FromQuery] int minApiLevel = 0, [FromQuery(Name = "track")] string? dip17Track = null)
{
if (this.pluginData.HasFailed && this.pluginData.Get()?.PluginMaster == null)
return StatusCode(500, "Precondition failed");

IReadOnlyList<PluginManifest>? pluginMaster;
if (!string.IsNullOrEmpty(dip17Track))
{
Expand All @@ -128,9 +119,6 @@ public IActionResult PluginMaster([FromQuery] bool proxy = true, [FromQuery] int
[HttpGet("{internalName}")]
public IActionResult Plugin(string internalName, [FromQuery(Name = "track")] string? dip17Track = null)
{
if (this.pluginData.HasFailed)
return StatusCode(500, "Precondition failed");

var master = this.pluginData.Get()!.PluginMaster;

if (!string.IsNullOrEmpty(dip17Track))
Expand All @@ -156,9 +144,6 @@ public class HistoryResponse
[HttpGet("{internalName}")]
public IActionResult History(string internalName, [FromQuery(Name = "track")] string? dip17Track = null)
{
if (this.pluginData.HasFailed)
return StatusCode(500, "Precondition failed");

if (string.IsNullOrEmpty(dip17Track))
{
dip17Track = Dip17SystemDefine.StableTrack;
Expand Down Expand Up @@ -195,9 +180,6 @@ public async Task<IActionResult> SetUseProxy([FromQuery] string key, [FromQuery]
[HttpGet]
public async Task<IActionResult> Meta()
{
if (this.pluginData.HasFailed || this.redis.HasFailed)
return StatusCode(500, "Precondition failed");

return new JsonResult(new PluginMeta
{
NumPlugins = this.pluginData.Get()!.PluginMaster!.Count,
Expand Down
2 changes: 1 addition & 1 deletion XLWebServices/Services/AssetCacheService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public AssetCacheAvailabilityFilter(FallibleService<AssetCacheService> assetCach

public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
if (_assetCache.HasFailed || _assetCache.Get()?.Assets == null)
if (_assetCache.HasFailed || _assetCache.Get()?.Response == null)
{
context.Result = new StatusCodeResult(503);
return;
Expand Down

0 comments on commit 30838ee

Please sign in to comment.