mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-10 11:58:19 +02:00
Fix Concurrency of DownloadClient LastExecutedRateLimit
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
using System.Net;
|
using System.Collections.Concurrent;
|
||||||
|
using System.Net;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
namespace API.MangaDownloadClients;
|
namespace API.MangaDownloadClients;
|
||||||
|
|
||||||
public abstract class DownloadClient
|
public abstract class DownloadClient
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<RequestType, DateTime> LastExecutedRateLimit = new();
|
private static readonly ConcurrentDictionary<RequestType, DateTime> LastExecutedRateLimit = new();
|
||||||
protected ILog Log { get; init; }
|
protected ILog Log { get; init; }
|
||||||
|
|
||||||
protected DownloadClient()
|
protected DownloadClient()
|
||||||
|
@@ -10,8 +10,6 @@ namespace API.MangaDownloadClients;
|
|||||||
|
|
||||||
public class FlareSolverrDownloadClient : DownloadClient
|
public class FlareSolverrDownloadClient : DownloadClient
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
internal override RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null)
|
internal override RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null)
|
||||||
{
|
{
|
||||||
if (clickButton is not null)
|
if (clickButton is not null)
|
||||||
|
@@ -5,6 +5,7 @@ namespace API.MangaDownloadClients;
|
|||||||
|
|
||||||
internal class HttpDownloadClient : DownloadClient
|
internal class HttpDownloadClient : DownloadClient
|
||||||
{
|
{
|
||||||
|
private static readonly FlareSolverrDownloadClient FlareSolverrDownloadClient = new();
|
||||||
internal override RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null)
|
internal override RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null)
|
||||||
{
|
{
|
||||||
if (clickButton is not null)
|
if (clickButton is not null)
|
||||||
@@ -36,7 +37,7 @@ internal class HttpDownloadClient : DownloadClient
|
|||||||
(s.Product?.Name ?? "").Contains("cloudflare", StringComparison.InvariantCultureIgnoreCase)))
|
(s.Product?.Name ?? "").Contains("cloudflare", StringComparison.InvariantCultureIgnoreCase)))
|
||||||
{
|
{
|
||||||
Log.Debug("Retrying with FlareSolverr!");
|
Log.Debug("Retrying with FlareSolverr!");
|
||||||
return new FlareSolverrDownloadClient().MakeRequestInternal(url, referrer, clickButton);
|
return FlareSolverrDownloadClient.MakeRequestInternal(url, referrer, clickButton);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user