From 53fe7ee98361af783205357dc6cbb65ba7917e2f Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 31 Jul 2023 22:47:14 +0200 Subject: [PATCH 1/2] Possible fix for #31 chapter regex --- Tranga/Connectors/Connector.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tranga/Connectors/Connector.cs b/Tranga/Connectors/Connector.cs index 391eaa9..997aeec 100644 --- a/Tranga/Connectors/Connector.cs +++ b/Tranga/Connectors/Connector.cs @@ -77,8 +77,8 @@ public abstract class Connector public Chapter[] SelectChapters(Publication publication, string searchTerm, string? language = null) { Chapter[] availableChapters = this.GetChapters(publication, language??"en"); - Regex volumeRegex = new ("((v(ol)*(olume)*)+ *([0-9]+(-[0-9]+)?){1})", RegexOptions.IgnoreCase); - Regex chapterRegex = new ("((c(h)*(hapter)*)+ *([0-9]+(-[0-9]+)?){1})", RegexOptions.IgnoreCase); + Regex volumeRegex = new ("((v(ol)*(olume)*){1} *([0-9]+(-[0-9]+)?){1})", RegexOptions.IgnoreCase); + Regex chapterRegex = new ("((c(h)*(hapter)*){1} *([0-9]+(-[0-9]+)?){1})", RegexOptions.IgnoreCase); Regex singleResultRegex = new("([0-9]+)", RegexOptions.IgnoreCase); Regex rangeResultRegex = new("([0-9]+(-[0-9]+))", RegexOptions.IgnoreCase); Regex allRegex = new("a(ll)?", RegexOptions.IgnoreCase); @@ -114,7 +114,7 @@ public abstract class Connector } else if (chapterRegex.IsMatch(searchTerm)) { - string chapter = volumeRegex.Match(searchTerm).Value; + string chapter = chapterRegex.Match(searchTerm).Value; if (rangeResultRegex.IsMatch(chapter)) { string range = rangeResultRegex.Match(chapter).Value; From a63154b581e3a028ddbba047323719741bef9b41 Mon Sep 17 00:00:00 2001 From: glax Date: Mon, 31 Jul 2023 22:47:35 +0200 Subject: [PATCH 2/2] Fix new installation startup issue where version would be null on new installs --- Tranga/Migrator.cs | 2 +- Tranga/Tranga.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Tranga/Migrator.cs b/Tranga/Migrator.cs index 7cf86f3..0ac0e91 100644 --- a/Tranga/Migrator.cs +++ b/Tranga/Migrator.cs @@ -9,7 +9,7 @@ namespace Tranga; public static class Migrator { - private static readonly ushort CurrentVersion = 17; + internal static readonly ushort CurrentVersion = 17; public static void Migrate(string settingsFilePath, Logger? logger) { if (!File.Exists(settingsFilePath)) diff --git a/Tranga/Tranga.cs b/Tranga/Tranga.cs index 63a51ae..997a787 100644 --- a/Tranga/Tranga.cs +++ b/Tranga/Tranga.cs @@ -38,8 +38,12 @@ public static class Tranga { logger.WriteLine("Tranga", $"Loading settings {settingsFilePath}"); settings = TrangaSettings.LoadSettings(settingsFilePath); - }else + } + else + { settings = new TrangaSettings(downloadFolderPath, applicationFolderPath); + settings.version = Migrator.CurrentVersion; + } Directory.CreateDirectory(settings.workingDirectory); Directory.CreateDirectory(settings.downloadLocation);