2
0

Cancel DownloadChapter-Task on removal

This commit is contained in:
glax 2023-06-11 19:16:05 +02:00
parent fcd81f03b3
commit a0469f3145

View File

@ -207,8 +207,11 @@ public class TaskManager
logger?.WriteLine(this.GetType().ToString(), $"Removing Task {removeTask}");
_allTasks.Remove(removeTask);
if (removeTask.GetType() == typeof(DownloadChapterTask))
{
_runningDownloadChapterTasks[(DownloadChapterTask)removeTask].Cancel();
_runningDownloadChapterTasks.Remove((DownloadChapterTask)removeTask);
}
}
public TrangaTask? AddTask(TrangaTask.Task taskType, string? connectorName, string? internalId,
TimeSpan reoccurrenceTime, string? language = "en")
@ -263,11 +266,12 @@ public class TaskManager
_allTasks.RemoveWhere(mTask =>
mTask.GetType() == typeof(DownloadNewChaptersTask) &&
((DownloadNewChaptersTask)mTask).publication.internalId == publicationId &&
((DownloadNewChaptersTask)mTask).connectorName == connectorName!);
_allTasks.RemoveWhere(mTask =>
((DownloadNewChaptersTask)mTask).connectorName == connectorName);
foreach(TrangaTask rTask in _allTasks.Where(mTask =>
mTask.GetType() == typeof(DownloadChapterTask) &&
((DownloadChapterTask)mTask).publication.internalId == publicationId &&
((DownloadChapterTask)mTask).connectorName == connectorName!);
((DownloadChapterTask)mTask).connectorName == connectorName))
DeleteTask(rTask);
}
break;
}