Fix Bug where all tasks would be deleted...
This commit is contained in:
parent
bbf05e3dec
commit
5ae02ee0ed
@ -79,9 +79,8 @@ app.MapPost("/Tasks/Create", (string taskType, string? connectorName, string? pu
|
||||
|
||||
app.MapDelete("/Tasks/Delete", (string taskType, string? connectorName, string? publicationId) =>
|
||||
{
|
||||
Publication? publication = taskManager.GetAllPublications().FirstOrDefault(pub => pub.internalId == publicationId);
|
||||
TrangaTask.Task task = Enum.Parse<TrangaTask.Task>(taskType);
|
||||
taskManager.DeleteTask(task, connectorName, publication);
|
||||
taskManager.DeleteTask(task, connectorName, publicationId);
|
||||
});
|
||||
|
||||
app.MapGet("/Tasks/Get", (string taskType, string? connectorName, string? searchString) =>
|
||||
|
@ -207,10 +207,10 @@ public class TaskManager
|
||||
/// </summary>
|
||||
/// <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 DeleteTask(TrangaTask.Task task, string? connectorName, Publication? publication)
|
||||
/// <param name="publicationId">Publication that was used</param>
|
||||
public void DeleteTask(TrangaTask.Task task, string? connectorName, string? publicationId)
|
||||
{
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Removing Task {task} {publication?.sortName}");
|
||||
logger?.WriteLine(this.GetType().ToString(), $"Removing Task {task} {publicationId}");
|
||||
|
||||
switch (task)
|
||||
{
|
||||
@ -220,12 +220,13 @@ public class TaskManager
|
||||
_allTasks.RemoveWhere(trangaTask => trangaTask.task is TrangaTask.Task.UpdateLibraries);
|
||||
break;
|
||||
case TrangaTask.Task.DownloadNewChapters:
|
||||
if(connectorName is null || publication is null)
|
||||
if (connectorName is null || publicationId is null)
|
||||
logger?.WriteLine(this.GetType().ToString(), "connectorName and publication can not be null");
|
||||
_allTasks.RemoveWhere(mTask =>
|
||||
else
|
||||
_allTasks.RemoveWhere(mTask =>
|
||||
mTask.GetType() == typeof(DownloadNewChaptersTask) &&
|
||||
((DownloadNewChaptersTask)mTask).publication.internalId != publication!.Value.publicationId &&
|
||||
((DownloadNewChaptersTask)mTask).connectorName != connectorName!);
|
||||
((DownloadNewChaptersTask)mTask).publication.internalId == publicationId &&
|
||||
((DownloadNewChaptersTask)mTask).connectorName == connectorName!);
|
||||
break;
|
||||
}
|
||||
ExportDataAndSettings();
|
||||
|
Loading…
Reference in New Issue
Block a user