Fixed some bugs relating to new Filepath of Applicationdata

This commit is contained in:
glax 2023-05-21 15:14:25 +02:00
parent 715cf1f4f3
commit b5bd5d6126
2 changed files with 14 additions and 7 deletions

View File

@ -15,11 +15,17 @@ public static class Tranga_Cli
public static void Main(string[] args) public static void Main(string[] args)
{ {
string applicationFolderPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tranga"); 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"); string settingsFilePath = Path.Join(applicationFolderPath, "data.json");
Logger logger = new(new[] { Logger.LoggerType.FileLogger }, null, null, Directory.CreateDirectory(applicationFolderPath);
Path.Join(logMessageFolderPath, $"log-{DateTime.Now:dd-M-yyyy-HH-mm-ss}.txt")); 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."); logger.WriteLine("Tranga_CLI", "Loading Taskmanager.");
TaskManager.SettingsData settings; TaskManager.SettingsData settings;

View File

@ -34,9 +34,8 @@ public class TaskManager
this.komga = new Komga(komgaBaseUrl, komgaUsername, komgaPassword, logger); this.komga = new Komga(komgaBaseUrl, komgaUsername, komgaPassword, logger);
this.settings = new SettingsData(downloadFolderPath, settingsFilePath, this.komga, this._allTasks); this.settings = new SettingsData(downloadFolderPath, settingsFilePath, this.komga, this._allTasks);
ExportData();
if (komgaBaseUrl != null && komgaUsername != null && komgaPassword != null)
this.komga = new Komga(komgaBaseUrl, komgaUsername, komgaPassword, logger);
this._connectors = new Connector[]{ new MangaDex(downloadFolderPath, logger) }; this._connectors = new Connector[]{ new MangaDex(downloadFolderPath, logger) };
foreach(Connector cConnector in this._connectors) foreach(Connector cConnector in this._connectors)
_taskQueue.Add(cConnector, new List<TrangaTask>()); _taskQueue.Add(cConnector, new List<TrangaTask>());
@ -50,6 +49,8 @@ public class TaskManager
this.logger = logger; this.logger = logger;
this._connectors = new Connector[]{ new MangaDex(settings.downloadLocation, logger) }; this._connectors = new Connector[]{ new MangaDex(settings.downloadLocation, logger) };
this.settings = settings; this.settings = settings;
ExportData();
foreach(Connector cConnector in this._connectors) foreach(Connector cConnector in this._connectors)
_taskQueue.Add(cConnector, new List<TrangaTask>()); _taskQueue.Add(cConnector, new List<TrangaTask>());
this.komga = settings.komga; this.komga = settings.komga;
@ -289,7 +290,7 @@ public class TaskManager
/// </summary> /// </summary>
private void ExportData() 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); string serializedData = JsonConvert.SerializeObject(settings);
File.WriteAllText(settings.settingsFilePath, serializedData); File.WriteAllText(settings.settingsFilePath, serializedData);