From 45ca2695eb9331d76088d7ffb122ea8306bb802c Mon Sep 17 00:00:00 2001 From: Alessandro Benetton Date: Sat, 1 Feb 2025 21:58:50 +0100 Subject: [PATCH] [postgres-Server-V2] feat: Convert DateTime.Now calls to UtcNow --- API/MangaDownloadClients/DownloadClient.cs | 6 +++--- API/Schema/Jobs/DownloadMangaCoverJob.cs | 1 - API/Schema/Jobs/DownloadSingleChapterJob.cs | 2 +- API/Schema/Manga.cs | 3 ++- API/Schema/MangaConnectors/Bato.cs | 2 +- API/Schema/MangaConnectors/MangaKatana.cs | 2 +- API/Tranga.cs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/API/MangaDownloadClients/DownloadClient.cs b/API/MangaDownloadClients/DownloadClient.cs index 9dcd049..d930852 100644 --- a/API/MangaDownloadClients/DownloadClient.cs +++ b/API/MangaDownloadClients/DownloadClient.cs @@ -24,9 +24,9 @@ internal abstract class DownloadClient : TrangaSettings.requestLimits[requestType]; TimeSpan timeBetweenRequests = TimeSpan.FromMinutes(1).Divide(rateLimit); - _lastExecutedRateLimit.TryAdd(requestType, DateTime.Now.Subtract(timeBetweenRequests)); + _lastExecutedRateLimit.TryAdd(requestType, DateTime.UtcNow.Subtract(timeBetweenRequests)); - TimeSpan rateLimitTimeout = timeBetweenRequests.Subtract(DateTime.Now.Subtract(_lastExecutedRateLimit[requestType])); + TimeSpan rateLimitTimeout = timeBetweenRequests.Subtract(DateTime.UtcNow.Subtract(_lastExecutedRateLimit[requestType])); if (rateLimitTimeout > TimeSpan.Zero) { @@ -34,7 +34,7 @@ internal abstract class DownloadClient } RequestResult result = MakeRequestInternal(url, referrer, clickButton); - _lastExecutedRateLimit[requestType] = DateTime.Now; + _lastExecutedRateLimit[requestType] = DateTime.UtcNow; return result; } diff --git a/API/Schema/Jobs/DownloadMangaCoverJob.cs b/API/Schema/Jobs/DownloadMangaCoverJob.cs index 56e630a..4c6403a 100644 --- a/API/Schema/Jobs/DownloadMangaCoverJob.cs +++ b/API/Schema/Jobs/DownloadMangaCoverJob.cs @@ -79,7 +79,6 @@ public class DownloadMangaCoverJob(string chapterId, string? parentJobId = null, { if (!TrangaSettings.bwImages && TrangaSettings.compression == 100) return; - DateTime start = DateTime.Now; using Image image = Image.Load(imagePath); File.Delete(imagePath); if(TrangaSettings.bwImages) diff --git a/API/Schema/Jobs/DownloadSingleChapterJob.cs b/API/Schema/Jobs/DownloadSingleChapterJob.cs index e6cee60..81ad66a 100644 --- a/API/Schema/Jobs/DownloadSingleChapterJob.cs +++ b/API/Schema/Jobs/DownloadSingleChapterJob.cs @@ -81,7 +81,7 @@ public class DownloadSingleChapterJob(string chapterId, string? parentJobId = nu { if (!TrangaSettings.bwImages && TrangaSettings.compression == 100) return; - DateTime start = DateTime.Now; + DateTime start = DateTime.UtcNow; using Image image = Image.Load(imagePath); File.Delete(imagePath); if(TrangaSettings.bwImages) diff --git a/API/Schema/Manga.cs b/API/Schema/Manga.cs index 6b58fa9..1055142 100644 --- a/API/Schema/Manga.cs +++ b/API/Schema/Manga.cs @@ -1,4 +1,4 @@ -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Runtime.InteropServices; using System.Text.RegularExpressions; @@ -30,6 +30,7 @@ public class Manga public float IgnoreChapterBefore { get; internal set; } public string MangaConnectorId { get; private set; } + public MangaConnector? MangaConnector { get; private set; } public ICollection? Authors { get; internal set; } diff --git a/API/Schema/MangaConnectors/Bato.cs b/API/Schema/MangaConnectors/Bato.cs index a2e8dc3..1d98e0e 100644 --- a/API/Schema/MangaConnectors/Bato.cs +++ b/API/Schema/MangaConnectors/Bato.cs @@ -97,7 +97,7 @@ public class Bato : MangaConnector if (!uint.TryParse( document.DocumentNode.SelectSingleNode("//span[text()='Original Publication:']/..").LastChild.InnerText.Split('-')[0], out uint year)) - year = (uint)DateTime.Now.Year; + year = (uint)DateTime.UtcNow.Year; string status = document.DocumentNode.SelectSingleNode("//span[text()='Original Publication:']/..") .ChildNodes[2].InnerText; diff --git a/API/Schema/MangaConnectors/MangaKatana.cs b/API/Schema/MangaConnectors/MangaKatana.cs index 0905db4..3bc77a3 100644 --- a/API/Schema/MangaConnectors/MangaKatana.cs +++ b/API/Schema/MangaConnectors/MangaKatana.cs @@ -127,7 +127,7 @@ public class MangaKatana : MangaConnector while (description.StartsWith('\n')) description = description.Substring(1); - uint year = (uint)DateTime.Now.Year; + uint year = (uint)DateTime.UtcNow.Year; string yearString = infoTable.Descendants("div").First(d => d.HasClass("updateAt")) .InnerText.Split('-')[^1]; diff --git a/API/Tranga.cs b/API/Tranga.cs index a9d9647..4e958b1 100644 --- a/API/Tranga.cs +++ b/API/Tranga.cs @@ -43,7 +43,7 @@ public static class Tranga if (notifications.Any()) { DateTime max = notifications.MaxBy(n => n.Date)!.Date; - if (DateTime.Now.Subtract(max) > TrangaSettings.NotificationUrgencyDelay(urgency)) + if (DateTime.UtcNow.Subtract(max) > TrangaSettings.NotificationUrgencyDelay(urgency)) { foreach (NotificationConnector notificationConnector in context.NotificationConnectors) {