Renamed ExportData to ExportDataAndSettings
This commit is contained in:
parent
2bc92556e3
commit
8619630269
@ -36,7 +36,7 @@ public class TaskManager
|
|||||||
newKomga = new Komga(komgaBaseUrl, komgaUsername, komgaPassword, logger);
|
newKomga = new Komga(komgaBaseUrl, komgaUsername, komgaPassword, logger);
|
||||||
|
|
||||||
this.settings = new TrangaSettings(downloadFolderPath, workingDirectory, newKomga);
|
this.settings = new TrangaSettings(downloadFolderPath, workingDirectory, newKomga);
|
||||||
ExportData();
|
ExportDataAndSettings();
|
||||||
|
|
||||||
this._connectors = new Connector[]{ new MangaDex(downloadFolderPath, imageCachePath, logger) };
|
this._connectors = new Connector[]{ new MangaDex(downloadFolderPath, imageCachePath, logger) };
|
||||||
foreach(Connector cConnector in this._connectors)
|
foreach(Connector cConnector in this._connectors)
|
||||||
@ -52,7 +52,7 @@ public class TaskManager
|
|||||||
settings.komga = new Komga(komgaUrl, komgaAuth, null);
|
settings.komga = new Komga(komgaUrl, komgaAuth, null);
|
||||||
if (downloadLocation is not null && downloadLocation.Length > 0)
|
if (downloadLocation is not null && downloadLocation.Length > 0)
|
||||||
settings.downloadLocation = downloadLocation;
|
settings.downloadLocation = downloadLocation;
|
||||||
ExportData();
|
ExportDataAndSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TaskManager(TrangaSettings settings, Logger? logger = null)
|
public TaskManager(TrangaSettings settings, Logger? logger = null)
|
||||||
@ -65,7 +65,7 @@ public class TaskManager
|
|||||||
|
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
ImportData();
|
ImportData();
|
||||||
ExportData();
|
ExportDataAndSettings();
|
||||||
Thread taskChecker = new(TaskCheckerThread);
|
Thread taskChecker = new(TaskCheckerThread);
|
||||||
taskChecker.Start();
|
taskChecker.Start();
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ public class TaskManager
|
|||||||
foreach (KeyValuePair<Connector, List<TrangaTask>> connectorTaskQueue in _taskQueue)
|
foreach (KeyValuePair<Connector, List<TrangaTask>> connectorTaskQueue in _taskQueue)
|
||||||
{
|
{
|
||||||
if(connectorTaskQueue.Value.RemoveAll(task => task.state == TrangaTask.ExecutionState.Waiting) > 0)
|
if(connectorTaskQueue.Value.RemoveAll(task => task.state == TrangaTask.ExecutionState.Waiting) > 0)
|
||||||
ExportData();
|
ExportDataAndSettings();
|
||||||
|
|
||||||
if (connectorTaskQueue.Value.Count > 0 && connectorTaskQueue.Value.All(task => task.state is TrangaTask.ExecutionState.Enqueued))
|
if (connectorTaskQueue.Value.Count > 0 && connectorTaskQueue.Value.All(task => task.state is TrangaTask.ExecutionState.Enqueued))
|
||||||
ExecuteTaskNow(connectorTaskQueue.Value.First());
|
ExecuteTaskNow(connectorTaskQueue.Value.First());
|
||||||
@ -169,9 +169,10 @@ public class TaskManager
|
|||||||
else
|
else
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Publication already exists {publication?.internalId}");
|
logger?.WriteLine(this.GetType().ToString(), $"Publication already exists {publication?.internalId}");
|
||||||
}
|
}
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Added new Task {newTask.ToString()}");
|
ExportDataAndSettings();
|
||||||
ExportData();
|
|
||||||
|
|
||||||
|
if (newTask is null)
|
||||||
|
throw new Exception("Invalid path");
|
||||||
return newTask;
|
return newTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +208,7 @@ public class TaskManager
|
|||||||
else
|
else
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"No Task {task} {publication?.sortName} {publication?.internalId} could be found.");
|
logger?.WriteLine(this.GetType().ToString(), $"No Task {task} {publication?.sortName} {publication?.internalId} could be found.");
|
||||||
}
|
}
|
||||||
ExportData();
|
ExportDataAndSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -286,7 +287,7 @@ public class TaskManager
|
|||||||
{
|
{
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Shutting down (forced={force})");
|
logger?.WriteLine(this.GetType().ToString(), $"Shutting down (forced={force})");
|
||||||
_continueRunning = false;
|
_continueRunning = false;
|
||||||
ExportData();
|
ExportDataAndSettings();
|
||||||
|
|
||||||
if(force)
|
if(force)
|
||||||
Environment.Exit(_allTasks.Count(task => task.state is TrangaTask.ExecutionState.Enqueued or TrangaTask.ExecutionState.Running));
|
Environment.Exit(_allTasks.Count(task => task.state is TrangaTask.ExecutionState.Enqueued or TrangaTask.ExecutionState.Running));
|
||||||
@ -322,7 +323,7 @@ public class TaskManager
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Exports data (settings, tasks) to file
|
/// Exports data (settings, tasks) to file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ExportData()
|
private void ExportDataAndSettings()
|
||||||
{
|
{
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Exporting settings to {settings.settingsFilePath}");
|
logger?.WriteLine(this.GetType().ToString(), $"Exporting settings to {settings.settingsFilePath}");
|
||||||
File.WriteAllText(settings.settingsFilePath, JsonConvert.SerializeObject(settings));
|
File.WriteAllText(settings.settingsFilePath, JsonConvert.SerializeObject(settings));
|
||||||
|
Loading…
Reference in New Issue
Block a user