From d5a10ca7eb083fb0f3bdfa83f4ffbdfc5954f7c5 Mon Sep 17 00:00:00 2001 From: Archi Date: Fri, 25 Jun 2021 14:43:46 +0200 Subject: [PATCH] Misc --- ArchiSteamFarm/Core/ASF.cs | 4 ++-- ArchiSteamFarm/IPC/Controllers/Api/StorageController.cs | 8 ++++---- ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs | 8 +++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ArchiSteamFarm/Core/ASF.cs b/ArchiSteamFarm/Core/ASF.cs index b4a97ec7e..df6078530 100644 --- a/ArchiSteamFarm/Core/ASF.cs +++ b/ArchiSteamFarm/Core/ASF.cs @@ -79,7 +79,7 @@ namespace ArchiSteamFarm.Core { internal static ICrossProcessSemaphore? LoginRateLimitingSemaphore { get; private set; } internal static ICrossProcessSemaphore? LoginSemaphore { get; private set; } internal static ICrossProcessSemaphore? RateLimitingSemaphore { get; private set; } - internal static ImmutableDictionary? WebLimitingSemaphores { get; private set; } + internal static ImmutableDictionary? WebLimitingSemaphores { get; private set; } private static readonly SemaphoreSlim UpdateSemaphore = new(1, 1); @@ -419,7 +419,7 @@ namespace ArchiSteamFarm.Core { LoginSemaphore ??= await PluginsCore.GetCrossProcessSemaphore(nameof(LoginSemaphore) + networkGroupText).ConfigureAwait(false); RateLimitingSemaphore ??= await PluginsCore.GetCrossProcessSemaphore(nameof(RateLimitingSemaphore) + networkGroupText).ConfigureAwait(false); - WebLimitingSemaphores ??= new Dictionary(4) { + WebLimitingSemaphores ??= new Dictionary(4) { { ArchiWebHandler.SteamCommunityURL, (await PluginsCore.GetCrossProcessSemaphore(nameof(ArchiWebHandler) + networkGroupText + "-" + nameof(ArchiWebHandler.SteamCommunityURL)).ConfigureAwait(false), new SemaphoreSlim(WebBrowser.MaxConnections, WebBrowser.MaxConnections)) }, { ArchiWebHandler.SteamHelpURL, (await PluginsCore.GetCrossProcessSemaphore(nameof(ArchiWebHandler) + networkGroupText + "-" + nameof(ArchiWebHandler.SteamHelpURL)).ConfigureAwait(false), new SemaphoreSlim(WebBrowser.MaxConnections, WebBrowser.MaxConnections)) }, { ArchiWebHandler.SteamStoreURL, (await PluginsCore.GetCrossProcessSemaphore(nameof(ArchiWebHandler) + networkGroupText + "-" + nameof(ArchiWebHandler.SteamStoreURL)).ConfigureAwait(false), new SemaphoreSlim(WebBrowser.MaxConnections, WebBrowser.MaxConnections)) }, diff --git a/ArchiSteamFarm/IPC/Controllers/Api/StorageController.cs b/ArchiSteamFarm/IPC/Controllers/Api/StorageController.cs index 122ac967b..64802732c 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/StorageController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/StorageController.cs @@ -27,12 +27,12 @@ using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; namespace ArchiSteamFarm.IPC.Controllers.Api { - [Route("Api/Storage")] + [Route("Api/Storage/{key:required}")] public sealed class StorageController : ArchiController { /// /// Deletes entry under specified key from ASF's persistent KeyValue JSON storage. /// - [HttpDelete("{key:required}")] + [HttpDelete] [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] public ActionResult StorageDelete(string key) { if (string.IsNullOrEmpty(key)) { @@ -51,7 +51,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { /// /// Loads entry under specified key from ASF's persistent KeyValue JSON storage. /// - [HttpGet("{key:required}")] + [HttpGet] [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] public ActionResult StorageGet(string key) { if (string.IsNullOrEmpty(key)) { @@ -71,7 +71,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { /// Saves entry under specified key in ASF's persistent KeyValue JSON storage. /// [Consumes("application/json")] - [HttpPost("{key:required}")] + [HttpPost] [ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.OK)] public ActionResult StoragePost(string key, [FromBody] JToken value) { if (string.IsNullOrEmpty(key)) { diff --git a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs index b12d3177e..1e41b6afb 100644 --- a/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs +++ b/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs @@ -1316,16 +1316,14 @@ namespace ArchiSteamFarm.Steam.Integration { return await function().ConfigureAwait(false); } - if (!ASF.WebLimitingSemaphores.TryGetValue(service, out (ICrossProcessSemaphore RateLimitingSemaphore, SemaphoreSlim? OpenConnectionsSemaphore) limiters)) { + if (!ASF.WebLimitingSemaphores.TryGetValue(service, out (ICrossProcessSemaphore RateLimitingSemaphore, SemaphoreSlim OpenConnectionsSemaphore) limiters)) { ASF.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(service), service)); limiters.RateLimitingSemaphore = ASF.RateLimitingSemaphore; } // Sending a request opens a new connection - if (limiters.OpenConnectionsSemaphore != null) { - await limiters.OpenConnectionsSemaphore.WaitAsync().ConfigureAwait(false); - } + await limiters.OpenConnectionsSemaphore.WaitAsync().ConfigureAwait(false); try { // It also increases number of requests @@ -1342,7 +1340,7 @@ namespace ArchiSteamFarm.Steam.Integration { return await function().ConfigureAwait(false); } finally { // We release open connections semaphore only once we're indeed done sending a particular request - limiters.OpenConnectionsSemaphore?.Release(); + limiters.OpenConnectionsSemaphore.Release(); } }