diff --git a/Tranga/Connectors/MangaDex.cs b/Tranga/Connectors/MangaDex.cs
index ce1f24d..5941ae3 100644
--- a/Tranga/Connectors/MangaDex.cs
+++ b/Tranga/Connectors/MangaDex.cs
@@ -21,7 +21,7 @@ public class MangaDex : Connector
public override Publication[] GetPublications(string publicationTitle = "")
{
- logger?.WriteLine(this.GetType().ToString(), $"Getting Publications");
+ logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})");
const int limit = 100; //How many values we want returned at once
int offset = 0; //"Page"
int total = int.MaxValue; //How many total results are there, is updated on first request
@@ -128,7 +128,7 @@ public class MangaDex : Connector
public override Chapter[] GetChapters(Publication publication, string language = "")
{
- logger?.WriteLine(this.GetType().ToString(), $"Getting Chapters");
+ logger?.WriteLine(this.GetType().ToString(), $"Getting Chapters {publication.sortName} (language={language})");
const int limit = 100; //How many values we want returned at once
int offset = 0; //"Page"
int total = int.MaxValue; //How many total results are there, is updated on first request
@@ -183,7 +183,7 @@ public class MangaDex : Connector
public override void DownloadChapter(Publication publication, Chapter chapter)
{
- logger?.WriteLine(this.GetType().ToString(), $"Download Chapter {publication.sortName} {chapter.sortNumber}");
+ logger?.WriteLine(this.GetType().ToString(), $"Download Chapter {publication.sortName} {chapter.volumeNumber}-{chapter.chapterNumber}");
//Request URLs for Chapter-Images
DownloadClient.RequestResult requestResult =
downloadClient.MakeRequest($"https://api.mangadex.org/at-home/server/{chapter.url}?forcePort443=false'");
diff --git a/Tranga/TaskExecutor.cs b/Tranga/TaskExecutor.cs
index d225409..aa8ca7a 100644
--- a/Tranga/TaskExecutor.cs
+++ b/Tranga/TaskExecutor.cs
@@ -15,6 +15,7 @@ public static class TaskExecutor
/// Parent
/// Task to execute
/// Current chapterCollection to update
+ ///
/// Is thrown when there is no Connector available with the name of the TrangaTask.connectorName
public static void Execute(TaskManager taskManager, TrangaTask trangaTask, Dictionary> chapterCollection, Logger? logger)
{
@@ -25,7 +26,7 @@ public static class TaskExecutor
return;
}
trangaTask.state = TrangaTask.ExecutionState.Running;
- logger?.WriteLine("TaskExecutor", $"Executing Task {trangaTask}");
+ logger?.WriteLine("TaskExecutor", $"Starting Task {trangaTask}");
//Connector is not needed for all tasks
Connector? connector = null;
@@ -49,9 +50,9 @@ public static class TaskExecutor
break;
}
- logger?.WriteLine("TaskExecutor", $"Task executed! {trangaTask}");
- trangaTask.state = TrangaTask.ExecutionState.Waiting;
+ logger?.WriteLine("TaskExecutor", $"Task finished! {trangaTask}");
trangaTask.lastExecuted = DateTime.Now;
+ trangaTask.state = TrangaTask.ExecutionState.Waiting;
}
///
diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs
index 05cae82..e60ccb6 100644
--- a/Tranga/TaskManager.cs
+++ b/Tranga/TaskManager.cs
@@ -60,6 +60,7 @@ public class TaskManager
///
private void TaskCheckerThread()
{
+ logger?.WriteLine(this.GetType().ToString(), "Starting TaskCheckerThread.");
while (_continueRunning)
{
//Check if previous tasks have finished and execute new tasks
@@ -120,7 +121,7 @@ public class TaskManager
public TrangaTask AddTask(TrangaTask.Task task, string? connectorName, Publication? publication, TimeSpan reoccurrence,
string language = "")
{
- logger?.WriteLine(this.GetType().ToString(), $"Adding new Task");
+ logger?.WriteLine(this.GetType().ToString(), $"Adding new Task {task} {connectorName} {publication?.sortName}");
if (task != TrangaTask.Task.UpdateKomgaLibrary && connectorName is null)
throw new ArgumentException($"connectorName can not be null for task {task}");
@@ -154,7 +155,7 @@ public class TaskManager
_allTasks.Add(newTask);
}
}
- logger?.WriteLine(this.GetType().ToString(), newTask.ToString());
+ logger?.WriteLine(this.GetType().ToString(), $"Added new Task {newTask.ToString()}");
ExportData(Directory.GetCurrentDirectory());
return newTask;
@@ -168,15 +169,23 @@ public class TaskManager
/// Publication that was used
public void RemoveTask(TrangaTask.Task task, string? connectorName, Publication? publication)
{
- logger?.WriteLine(this.GetType().ToString(), $"Removing Task {task}");
+ logger?.WriteLine(this.GetType().ToString(), $"Removing Task {task} {publication?.sortName}");
if (task == TrangaTask.Task.UpdateKomgaLibrary)
+ {
_allTasks.RemoveWhere(uTask => uTask.task == TrangaTask.Task.UpdateKomgaLibrary);
+ logger?.WriteLine(this.GetType().ToString(), $"Removed Task {task}");
+ }
else if (connectorName is null)
throw new ArgumentException($"connectorName can not be null for Task {task}");
else
- _allTasks.RemoveWhere(trangaTask =>
+ {
+ if(_allTasks.RemoveWhere(trangaTask =>
trangaTask.task == task && trangaTask.connectorName == connectorName &&
- trangaTask.publication?.downloadUrl == publication?.downloadUrl);
+ trangaTask.publication?.downloadUrl == publication?.downloadUrl) > 0)
+ logger?.WriteLine(this.GetType().ToString(), $"Removed Task {task} {publication?.sortName} {publication?.downloadUrl}.");
+ else
+ logger?.WriteLine(this.GetType().ToString(), $"No Task {task} {publication?.sortName} {publication?.downloadUrl} could be found.");
+ }
ExportData(Directory.GetCurrentDirectory());
}
@@ -231,6 +240,7 @@ public class TaskManager
//Wait for tasks to finish
while(_allTasks.Any(task => task.state is TrangaTask.ExecutionState.Running or TrangaTask.ExecutionState.Enqueued))
Thread.Sleep(10);
+ logger?.WriteLine(this.GetType().ToString(), "Tasks finished. Bye!");
Environment.Exit(0);
}