2
0

Remove UpdateLibrariesTask

This commit is contained in:
glax 2023-07-28 10:41:20 +02:00
parent f947c37bd6
commit de14ff0b75
2 changed files with 3 additions and 37 deletions

View File

@ -12,7 +12,6 @@ namespace Tranga;
/// Stores information on Task, when implementing new Tasks also update the serializer /// Stores information on Task, when implementing new Tasks also update the serializer
/// </summary> /// </summary>
[JsonDerivedType(typeof(MonitorPublicationTask), 2)] [JsonDerivedType(typeof(MonitorPublicationTask), 2)]
[JsonDerivedType(typeof(UpdateLibrariesTask), 3)]
[JsonDerivedType(typeof(DownloadChapterTask), 4)] [JsonDerivedType(typeof(DownloadChapterTask), 4)]
public abstract class TrangaTask public abstract class TrangaTask
{ {
@ -131,19 +130,19 @@ public abstract class TrangaTask
return objectType == typeof(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); JObject jo = JObject.Load(reader);
if (jo["task"]!.Value<Int64>() == (Int64)Task.MonitorPublication) if (jo["task"]!.Value<Int64>() == (Int64)Task.MonitorPublication)
return jo.ToObject<MonitorPublicationTask>(serializer)!; return jo.ToObject<MonitorPublicationTask>(serializer)!;
if (jo["task"]!.Value<Int64>() == (Int64)Task.UpdateLibraries) if (jo["task"]!.Value<Int64>() == (Int64)Task.UpdateLibraries)
return jo.ToObject<UpdateLibrariesTask>(serializer)!; return null;
if (jo["task"]!.Value<Int64>() == (Int64)Task.DownloadChapter) if (jo["task"]!.Value<Int64>() == (Int64)Task.DownloadChapter)
return jo.ToObject<DownloadChapterTask>(serializer)!; return jo.ToObject<DownloadChapterTask>(serializer)!;
throw new Exception(); throw new Exception($"Deserialization: Unknown type {objectType} for TrangaTask");
} }
public override bool CanWrite => false; public override bool CanWrite => false;

View File

@ -1,33 +0,0 @@
using System.Net;
using Logging;
namespace Tranga.TrangaTasks;
/// <summary>
/// LEGACY DEPRECATED
/// </summary>
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;
}
}