2 Commits

Author SHA1 Message Date
eddf50483f Fixed some nullable types 2023-05-22 21:44:52 +02:00
a71d65e666 Fix negative sleep time 2023-05-22 21:41:11 +02:00
3 changed files with 10 additions and 4 deletions

View File

@ -20,6 +20,10 @@ public abstract class Connector
{ {
this.downloadLocation = downloadLocation; this.downloadLocation = downloadLocation;
this.logger = logger; this.logger = logger;
this.downloadClient = new DownloadClient(new Dictionary<byte, int>()
{
//RequestTypes for RateLimits
}, logger);
} }
public abstract string name { get; } //Name of the Connector (e.g. Website) public abstract string name { get; } //Name of the Connector (e.g. Website)
@ -205,6 +209,7 @@ public abstract class Connector
TimeSpan rateLimitTimeout = _rateLimit[requestType] TimeSpan rateLimitTimeout = _rateLimit[requestType]
.Subtract(DateTime.Now.Subtract(_lastExecutedRateLimit[requestType])); .Subtract(DateTime.Now.Subtract(_lastExecutedRateLimit[requestType]));
if(rateLimitTimeout > TimeSpan.Zero)
Thread.Sleep(rateLimitTimeout); Thread.Sleep(rateLimitTimeout);
HttpResponseMessage? response = null; HttpResponseMessage? response = null;
@ -218,6 +223,7 @@ public abstract class Connector
} }
catch (HttpRequestException e) catch (HttpRequestException e)
{ {
logger?.WriteLine(this.GetType().ToString(), e.Message);
Thread.Sleep(_rateLimit[requestType] * 2); Thread.Sleep(_rateLimit[requestType] * 2);
} }
} }

View File

@ -276,7 +276,7 @@ public class MangaDex : Connector
return; return;
} }
if (publication.posterUrl is null || !(bool)publication.posterUrl?.Contains("http")) if (publication.posterUrl is null || publication.posterUrl!.Contains("http"))
{ {
logger?.WriteLine(this.GetType().ToString(), $"No Poster-URL in publication"); logger?.WriteLine(this.GetType().ToString(), $"No Poster-URL in publication");
return; return;

View File

@ -25,7 +25,7 @@ public class TaskManager
/// <param name="komgaUsername">The Komga username</param> /// <param name="komgaUsername">The Komga username</param>
/// <param name="komgaPassword">The Komga password</param> /// <param name="komgaPassword">The Komga password</param>
/// <param name="logger"></param> /// <param name="logger"></param>
public TaskManager(string downloadFolderPath, string? workingDirectory = null, string? komgaBaseUrl = null, string? komgaUsername = null, string? komgaPassword = null, Logger? logger = null) public TaskManager(string downloadFolderPath, string workingDirectory, string? komgaBaseUrl = null, string? komgaUsername = null, string? komgaPassword = null, Logger? logger = null)
{ {
this.logger = logger; this.logger = logger;
_allTasks = new HashSet<TrangaTask>(); _allTasks = new HashSet<TrangaTask>();
@ -170,7 +170,7 @@ public class TaskManager
_allTasks.Add(newTask); _allTasks.Add(newTask);
} }
else else
logger.WriteLine(this.GetType().ToString(), $"Publication already exists {publication?.internalId}"); logger?.WriteLine(this.GetType().ToString(), $"Publication already exists {publication?.internalId}");
} }
logger?.WriteLine(this.GetType().ToString(), $"Added new Task {newTask.ToString()}"); logger?.WriteLine(this.GetType().ToString(), $"Added new Task {newTask.ToString()}");
ExportData(); ExportData();