Removed UpdateLibraryTask (deprecated).
Libraries will be updated on new Chapters downloaded. Added Migrator, for future file-changes
This commit is contained in:
parent
42c2876188
commit
fa69f4488f
@ -21,7 +21,7 @@ public class RequestHandler
|
|||||||
new(HttpMethod.Get, "/Tasks/Types", Array.Empty<string>()),
|
new(HttpMethod.Get, "/Tasks/Types", Array.Empty<string>()),
|
||||||
new(HttpMethod.Post, "/Tasks/CreateMonitorTask",
|
new(HttpMethod.Post, "/Tasks/CreateMonitorTask",
|
||||||
new[] { "connectorName", "internalId", "reoccurrenceTime", "language?" }),
|
new[] { "connectorName", "internalId", "reoccurrenceTime", "language?" }),
|
||||||
new(HttpMethod.Post, "/Tasks/CreateUpdateLibraryTask", new[] { "reoccurrenceTime" }),
|
//DEPRECATED new(HttpMethod.Post, "/Tasks/CreateUpdateLibraryTask", new[] { "reoccurrenceTime" }),
|
||||||
new(HttpMethod.Post, "/Tasks/CreateDownloadChaptersTask",
|
new(HttpMethod.Post, "/Tasks/CreateDownloadChaptersTask",
|
||||||
new[] { "connectorName", "internalId", "chapters", "language?" }),
|
new[] { "connectorName", "internalId", "chapters", "language?" }),
|
||||||
new(HttpMethod.Get, "/Tasks", new[] { "taskType", "connectorName?", "publicationId?" }),
|
new(HttpMethod.Get, "/Tasks", new[] { "taskType", "connectorName?", "publicationId?" }),
|
||||||
@ -162,11 +162,11 @@ public class RequestHandler
|
|||||||
return;
|
return;
|
||||||
_taskManager.AddTask(new MonitorPublicationTask(connectorName1, (Publication)publication1, TimeSpan.Parse(reoccurrenceTime1), language1 ?? "en"));
|
_taskManager.AddTask(new MonitorPublicationTask(connectorName1, (Publication)publication1, TimeSpan.Parse(reoccurrenceTime1), language1 ?? "en"));
|
||||||
break;
|
break;
|
||||||
case "/Tasks/CreateUpdateLibraryTask":
|
case "/Tasks/CreateUpdateLibraryTask": // DEPRECATED
|
||||||
variables.TryGetValue("reoccurrenceTime", out string? reoccurrenceTime2);
|
/*variables.TryGetValue("reoccurrenceTime", out string? reoccurrenceTime2);
|
||||||
if (reoccurrenceTime2 is null)
|
if (reoccurrenceTime2 is null)
|
||||||
return;
|
return;
|
||||||
_taskManager.AddTask(new UpdateLibrariesTask(TimeSpan.Parse(reoccurrenceTime2)));
|
_taskManager.AddTask(new UpdateLibrariesTask(TimeSpan.Parse(reoccurrenceTime2)));*/
|
||||||
break;
|
break;
|
||||||
case "/Tasks/CreateDownloadChaptersTask":
|
case "/Tasks/CreateDownloadChaptersTask":
|
||||||
variables.TryGetValue("connectorName", out string? connectorName2);
|
variables.TryGetValue("connectorName", out string? connectorName2);
|
||||||
|
27
Tranga/Migrate.cs
Normal file
27
Tranga/Migrate.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Tranga;
|
||||||
|
|
||||||
|
public static class Migrate
|
||||||
|
{
|
||||||
|
private static readonly ushort CurrentVersion = 16;
|
||||||
|
public static void Files(TrangaSettings settings)
|
||||||
|
{
|
||||||
|
settings.version ??= 15;
|
||||||
|
switch (settings.version)
|
||||||
|
{
|
||||||
|
case 15:
|
||||||
|
RemoveUpdateLibraryTask(settings);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.version = CurrentVersion;
|
||||||
|
settings.ExportSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RemoveUpdateLibraryTask(TrangaSettings settings)
|
||||||
|
{
|
||||||
|
List<TrangaTask> tasks = JsonConvert.DeserializeObject<List<TrangaTask>>(settings.tasksFilePath)!;
|
||||||
|
tasks.RemoveAll(t => t.task == TrangaTask.Task.UpdateLibraries);
|
||||||
|
}
|
||||||
|
}
|
@ -37,6 +37,7 @@ public class TaskManager
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
Migrate.Files(settings);
|
||||||
ImportData();
|
ImportData();
|
||||||
ExportDataAndSettings();
|
ExportDataAndSettings();
|
||||||
Thread taskChecker = new(TaskCheckerThread);
|
Thread taskChecker = new(TaskCheckerThread);
|
||||||
|
@ -15,6 +15,7 @@ public class TrangaSettings
|
|||||||
[JsonIgnore] public string coverImageCache => Path.Join(workingDirectory, "imageCache");
|
[JsonIgnore] public string coverImageCache => Path.Join(workingDirectory, "imageCache");
|
||||||
public HashSet<LibraryManager> libraryManagers { get; }
|
public HashSet<LibraryManager> libraryManagers { get; }
|
||||||
public HashSet<NotificationManager> notificationManagers { get; }
|
public HashSet<NotificationManager> notificationManagers { get; }
|
||||||
|
public ushort? version { get; set; }
|
||||||
|
|
||||||
public TrangaSettings(string downloadLocation, string workingDirectory, HashSet<LibraryManager>? libraryManagers,
|
public TrangaSettings(string downloadLocation, string workingDirectory, HashSet<LibraryManager>? libraryManagers,
|
||||||
HashSet<NotificationManager>? notificationManagers)
|
HashSet<NotificationManager>? notificationManagers)
|
||||||
|
@ -3,6 +3,9 @@ using Logging;
|
|||||||
|
|
||||||
namespace Tranga.TrangaTasks;
|
namespace Tranga.TrangaTasks;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LEGACY DEPRECATED
|
||||||
|
/// </summary>
|
||||||
public class UpdateLibrariesTask : TrangaTask
|
public class UpdateLibrariesTask : TrangaTask
|
||||||
{
|
{
|
||||||
public UpdateLibrariesTask(TimeSpan reoccurrence) : base(Task.UpdateLibraries, reoccurrence)
|
public UpdateLibrariesTask(TimeSpan reoccurrence) : base(Task.UpdateLibraries, reoccurrence)
|
||||||
|
Loading…
Reference in New Issue
Block a user