From f2bd5c5e85f39f3a0e49ecfa9724e4296920531f Mon Sep 17 00:00:00 2001 From: glax Date: Sat, 20 May 2023 15:46:40 +0200 Subject: [PATCH] Fixed removeTask for tasks without connector --- Tranga/Komga.cs | 2 +- Tranga/TaskManager.cs | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Tranga/Komga.cs b/Tranga/Komga.cs index c6b9fba..dd9095e 100644 --- a/Tranga/Komga.cs +++ b/Tranga/Komga.cs @@ -45,7 +45,7 @@ public class Komga HashSet ret = new(); - foreach (JsonNode jsonNode in result) + foreach (JsonNode? jsonNode in result) { var jObject = (JsonObject?)jsonNode; string libraryId = jObject!["id"]!.GetValue(); diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs index f25fa54..2260fb2 100644 --- a/Tranga/TaskManager.cs +++ b/Tranga/TaskManager.cs @@ -153,11 +153,16 @@ public class TaskManager /// TrangaTask.Task type /// Name of Connector that was used /// Publication that was used - 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()); }