From 5a44e3b8b99f0908ca6a45f623819c93070210f8 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 30 May 2023 19:32:22 +0200 Subject: [PATCH] #25 only replace settings if parameter actually contains value. --- Tranga/TaskManager.cs | 9 ++++----- Tranga/TrangaSettings.cs | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Tranga/TaskManager.cs b/Tranga/TaskManager.cs index ddf35b5..d051bc8 100644 --- a/Tranga/TaskManager.cs +++ b/Tranga/TaskManager.cs @@ -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(); } diff --git a/Tranga/TrangaSettings.cs b/Tranga/TrangaSettings.cs index bb2b065..ca2acd3 100644 --- a/Tranga/TrangaSettings.cs +++ b/Tranga/TrangaSettings.cs @@ -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;