parent
485637d99a
commit
9f38dc3b6a
@ -12,6 +12,7 @@ namespace Tranga;
|
||||
/// Stores information on Task, when implementing new Tasks also update the serializer
|
||||
/// </summary>
|
||||
[JsonDerivedType(typeof(MonitorPublicationTask), 2)]
|
||||
[JsonDerivedType(typeof(UpdateLibrariesTask), 3)]
|
||||
[JsonDerivedType(typeof(DownloadChapterTask), 4)]
|
||||
public abstract class TrangaTask
|
||||
{
|
||||
@ -130,19 +131,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>() == (Int64)Task.MonitorPublication)
|
||||
return jo.ToObject<MonitorPublicationTask>(serializer)!;
|
||||
|
||||
if (jo["task"]!.Value<Int64>() == (Int64)Task.UpdateLibraries)
|
||||
return null;
|
||||
return jo.ToObject<UpdateLibrariesTask>(serializer)!;
|
||||
|
||||
if (jo["task"]!.Value<Int64>() == (Int64)Task.DownloadChapter)
|
||||
return jo.ToObject<DownloadChapterTask>(serializer)!;
|
||||
|
||||
throw new Exception($"Deserialization: Unknown type {objectType} for TrangaTask");
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
public override bool CanWrite => false;
|
||||
|
33
Tranga/TrangaTasks/UpdateLibrariesTask.cs
Normal file
33
Tranga/TrangaTasks/UpdateLibrariesTask.cs
Normal file
@ -0,0 +1,33 @@
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user