Fixed removeTask for tasks without connector

This commit is contained in:
glax 2023-05-20 15:46:40 +02:00
parent f396640001
commit f2bd5c5e85
2 changed files with 10 additions and 5 deletions

View File

@ -45,7 +45,7 @@ public class Komga
HashSet<KomgaLibrary> ret = new();
foreach (JsonNode jsonNode in result)
foreach (JsonNode? jsonNode in result)
{
var jObject = (JsonObject?)jsonNode;
string libraryId = jObject!["id"]!.GetValue<string>();

View File

@ -153,11 +153,16 @@ public class TaskManager
/// <param name="task">TrangaTask.Task type</param>
/// <param name="connectorName">Name of Connector that was used</param>
/// <param name="publication">Publication that was used</param>
public void RemoveTask(TrangaTask.Task task, string connectorName, Publication? publication)
public void RemoveTask(TrangaTask.Task task, string? connectorName, Publication? publication)
{
_allTasks.RemoveWhere(trangaTask =>
trangaTask.task == task && trangaTask.connectorName == connectorName &&
trangaTask.publication?.downloadUrl == publication?.downloadUrl);
if (task == TrangaTask.Task.UpdateKomgaLibrary)
_allTasks.RemoveWhere(uTask => uTask.task == TrangaTask.Task.UpdateKomgaLibrary);
else if (connectorName is null)
throw new ArgumentException($"connectorName can not be null for Task {task}");
else
_allTasks.RemoveWhere(trangaTask =>
trangaTask.task == task && trangaTask.connectorName == connectorName &&
trangaTask.publication?.downloadUrl == publication?.downloadUrl);
ExportData(Directory.GetCurrentDirectory());
}