From de14ff0b7505415bcac439fec8eaa8023a74d3dc Mon Sep 17 00:00:00 2001 From: glax Date: Fri, 28 Jul 2023 10:41:20 +0200 Subject: [PATCH] Remove UpdateLibrariesTask --- Tranga/TrangaTask.cs | 7 +++-- Tranga/TrangaTasks/UpdateLibrariesTask.cs | 33 ----------------------- 2 files changed, 3 insertions(+), 37 deletions(-) delete mode 100644 Tranga/TrangaTasks/UpdateLibrariesTask.cs diff --git a/Tranga/TrangaTask.cs b/Tranga/TrangaTask.cs index 6dbf0d1..6c90544 100644 --- a/Tranga/TrangaTask.cs +++ b/Tranga/TrangaTask.cs @@ -12,7 +12,6 @@ namespace Tranga; /// Stores information on Task, when implementing new Tasks also update the serializer /// [JsonDerivedType(typeof(MonitorPublicationTask), 2)] -[JsonDerivedType(typeof(UpdateLibrariesTask), 3)] [JsonDerivedType(typeof(DownloadChapterTask), 4)] public abstract class TrangaTask { @@ -131,19 +130,19 @@ public abstract class TrangaTask return objectType == typeof(TrangaTask); } - public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { JObject jo = JObject.Load(reader); if (jo["task"]!.Value() == (Int64)Task.MonitorPublication) return jo.ToObject(serializer)!; if (jo["task"]!.Value() == (Int64)Task.UpdateLibraries) - return jo.ToObject(serializer)!; + return null; if (jo["task"]!.Value() == (Int64)Task.DownloadChapter) return jo.ToObject(serializer)!; - throw new Exception(); + throw new Exception($"Deserialization: Unknown type {objectType} for TrangaTask"); } public override bool CanWrite => false; diff --git a/Tranga/TrangaTasks/UpdateLibrariesTask.cs b/Tranga/TrangaTasks/UpdateLibrariesTask.cs deleted file mode 100644 index 2ecf6f2..0000000 --- a/Tranga/TrangaTasks/UpdateLibrariesTask.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Net; -using Logging; - -namespace Tranga.TrangaTasks; - -/// -/// LEGACY DEPRECATED -/// -public class UpdateLibrariesTask : TrangaTask -{ - public UpdateLibrariesTask(TimeSpan reoccurrence) : base(Task.UpdateLibraries, reoccurrence) - { - } - - protected override HttpStatusCode ExecuteTask(TaskManager taskManager, Logger? logger, CancellationToken? cancellationToken = null) - { - if (cancellationToken?.IsCancellationRequested ?? false) - return HttpStatusCode.RequestTimeout; - foreach(LibraryManager lm in taskManager.settings.libraryManagers) - lm.UpdateLibrary(); - return HttpStatusCode.OK; - } - - public override TrangaTask Clone() - { - return new UpdateLibrariesTask(this.reoccurrence); - } - - protected override double GetProgress() - { - return 1; - } -} \ No newline at end of file