From fab70501ce7afb6ce0ae227d47252e6c878e4870 Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 21 Jul 2025 13:06:35 +0200 Subject: [PATCH] Fix Concurrency of DownloadClient LastExecutedRateLimit --- API/MangaDownloadClients/DownloadClient.cs | 5 +++-- API/MangaDownloadClients/FlareSolverrDownloadClient.cs | 2 -- API/MangaDownloadClients/HttpDownloadClient.cs | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/API/MangaDownloadClients/DownloadClient.cs b/API/MangaDownloadClients/DownloadClient.cs index 0906b14..dd12ecb 100644 --- a/API/MangaDownloadClients/DownloadClient.cs +++ b/API/MangaDownloadClients/DownloadClient.cs @@ -1,11 +1,12 @@ -using System.Net; +using System.Collections.Concurrent; +using System.Net; using log4net; namespace API.MangaDownloadClients; public abstract class DownloadClient { - private static readonly Dictionary LastExecutedRateLimit = new(); + private static readonly ConcurrentDictionary LastExecutedRateLimit = new(); protected ILog Log { get; init; } protected DownloadClient() diff --git a/API/MangaDownloadClients/FlareSolverrDownloadClient.cs b/API/MangaDownloadClients/FlareSolverrDownloadClient.cs index a29c9c8..f4861c8 100644 --- a/API/MangaDownloadClients/FlareSolverrDownloadClient.cs +++ b/API/MangaDownloadClients/FlareSolverrDownloadClient.cs @@ -10,8 +10,6 @@ namespace API.MangaDownloadClients; public class FlareSolverrDownloadClient : DownloadClient { - - internal override RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null) { if (clickButton is not null) diff --git a/API/MangaDownloadClients/HttpDownloadClient.cs b/API/MangaDownloadClients/HttpDownloadClient.cs index 9b53847..9735883 100644 --- a/API/MangaDownloadClients/HttpDownloadClient.cs +++ b/API/MangaDownloadClients/HttpDownloadClient.cs @@ -5,6 +5,7 @@ namespace API.MangaDownloadClients; internal class HttpDownloadClient : DownloadClient { + private static readonly FlareSolverrDownloadClient FlareSolverrDownloadClient = new(); internal override RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null) { if (clickButton is not null) @@ -36,7 +37,7 @@ internal class HttpDownloadClient : DownloadClient (s.Product?.Name ?? "").Contains("cloudflare", StringComparison.InvariantCultureIgnoreCase))) { Log.Debug("Retrying with FlareSolverr!"); - return new FlareSolverrDownloadClient().MakeRequestInternal(url, referrer, clickButton); + return FlareSolverrDownloadClient.MakeRequestInternal(url, referrer, clickButton); } else {