#25 only replace settings if parameter actually contains value.

This commit is contained in:
glax 2023-05-30 19:32:22 +02:00
parent 732c2f119c
commit 5a44e3b8b9
2 changed files with 6 additions and 5 deletions

View File

@ -48,11 +48,10 @@ public class TaskManager
public void UpdateSettings(string? downloadLocation, string? komgaUrl, string? komgaAuth)
{
Komga? komga = null;
if (komgaUrl is not null && komgaAuth is not null)
komga = new Komga(komgaUrl, komgaAuth, null);
settings.downloadLocation = downloadLocation ?? settings.downloadLocation;
settings.komga = komga ?? komga;
if (komgaUrl is not null && komgaAuth is not null && komgaUrl.Length > 0 && komgaAuth.Length > 0)
settings.komga = new Komga(komgaUrl, komgaAuth, null);
if (downloadLocation is not null && downloadLocation.Length > 0)
settings.downloadLocation = downloadLocation;
ExportData();
}

View File

@ -14,6 +14,8 @@ public class TrangaSettings
public TrangaSettings(string downloadLocation, string workingDirectory, Komga? komga)
{
if (downloadLocation.Length < 1 || workingDirectory.Length < 1)
throw new ArgumentException("Download-location and working-directory paths can not be empty!");
this.workingDirectory = workingDirectory;
this.downloadLocation = downloadLocation;
this.komga = komga;