diff --git a/Tranga-CLI/Tranga_Cli.cs b/Tranga-CLI/Tranga_Cli.cs index 221009d..e4759f6 100644 --- a/Tranga-CLI/Tranga_Cli.cs +++ b/Tranga-CLI/Tranga_Cli.cs @@ -15,11 +15,17 @@ public static class Tranga_Cli public static void Main(string[] args) { string applicationFolderPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tranga"); - string logMessageFolderPath = Path.Join(applicationFolderPath, "logs"); + string logsFolderPath = Path.Join(applicationFolderPath, "logs"); + string logFilePath = Path.Join(logsFolderPath, $"log-{DateTime.Now:dd-M-yyyy-HH-mm-ss}.txt"); string settingsFilePath = Path.Join(applicationFolderPath, "data.json"); - Logger logger = new(new[] { Logger.LoggerType.FileLogger }, null, null, - Path.Join(logMessageFolderPath, $"log-{DateTime.Now:dd-M-yyyy-HH-mm-ss}.txt")); + Directory.CreateDirectory(applicationFolderPath); + Directory.CreateDirectory(logsFolderPath); + + Console.WriteLine($"Logfile-Path: {logFilePath}"); + Console.WriteLine($"Settings-File-Path: {settingsFilePath}"); + + Logger logger = new(new[] { Logger.LoggerType.FileLogger }, null, null, logFilePath); logger.WriteLine("Tranga_CLI", "Loading Taskmanager."); TaskManager.SettingsData settings; diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs index 063ebe5..7e454ed 100644 --- a/Tranga/TaskManager.cs +++ b/Tranga/TaskManager.cs @@ -34,9 +34,8 @@ public class TaskManager this.komga = new Komga(komgaBaseUrl, komgaUsername, komgaPassword, logger); this.settings = new SettingsData(downloadFolderPath, settingsFilePath, this.komga, this._allTasks); - - if (komgaBaseUrl != null && komgaUsername != null && komgaPassword != null) - this.komga = new Komga(komgaBaseUrl, komgaUsername, komgaPassword, logger); + ExportData(); + this._connectors = new Connector[]{ new MangaDex(downloadFolderPath, logger) }; foreach(Connector cConnector in this._connectors) _taskQueue.Add(cConnector, new List()); @@ -50,6 +49,8 @@ public class TaskManager this.logger = logger; this._connectors = new Connector[]{ new MangaDex(settings.downloadLocation, logger) }; this.settings = settings; + ExportData(); + foreach(Connector cConnector in this._connectors) _taskQueue.Add(cConnector, new List()); this.komga = settings.komga; @@ -289,7 +290,7 @@ public class TaskManager /// private void ExportData() { - logger?.WriteLine(this.GetType().ToString(), $"Exporting data to data.json"); + logger?.WriteLine(this.GetType().ToString(), $"Exporting data to {settings.settingsFilePath}"); string serializedData = JsonConvert.SerializeObject(settings); File.WriteAllText(settings.settingsFilePath, serializedData);