Merge pull request '#31 #40' (!52) from cuttingedge into master

Reviewed-on: #52
This commit is contained in:
glax 2023-07-31 22:50:22 +02:00
commit 00c1cd56b8
3 changed files with 9 additions and 5 deletions

View File

@ -77,8 +77,8 @@ public abstract class Connector
public Chapter[] SelectChapters(Publication publication, string searchTerm, string? language = null) public Chapter[] SelectChapters(Publication publication, string searchTerm, string? language = null)
{ {
Chapter[] availableChapters = this.GetChapters(publication, language??"en"); Chapter[] availableChapters = this.GetChapters(publication, language??"en");
Regex volumeRegex = new ("((v(ol)*(olume)*)+ *([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)*)+ *([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 singleResultRegex = new("([0-9]+)", RegexOptions.IgnoreCase);
Regex rangeResultRegex = new("([0-9]+(-[0-9]+))", RegexOptions.IgnoreCase); Regex rangeResultRegex = new("([0-9]+(-[0-9]+))", RegexOptions.IgnoreCase);
Regex allRegex = new("a(ll)?", RegexOptions.IgnoreCase); Regex allRegex = new("a(ll)?", RegexOptions.IgnoreCase);
@ -114,7 +114,7 @@ public abstract class Connector
} }
else if (chapterRegex.IsMatch(searchTerm)) else if (chapterRegex.IsMatch(searchTerm))
{ {
string chapter = volumeRegex.Match(searchTerm).Value; string chapter = chapterRegex.Match(searchTerm).Value;
if (rangeResultRegex.IsMatch(chapter)) if (rangeResultRegex.IsMatch(chapter))
{ {
string range = rangeResultRegex.Match(chapter).Value; string range = rangeResultRegex.Match(chapter).Value;

View File

@ -9,7 +9,7 @@ namespace Tranga;
public static class Migrator public static class Migrator
{ {
private static readonly ushort CurrentVersion = 17; internal static readonly ushort CurrentVersion = 17;
public static void Migrate(string settingsFilePath, Logger? logger) public static void Migrate(string settingsFilePath, Logger? logger)
{ {
if (!File.Exists(settingsFilePath)) if (!File.Exists(settingsFilePath))

View File

@ -38,8 +38,12 @@ public static class Tranga
{ {
logger.WriteLine("Tranga", $"Loading settings {settingsFilePath}"); logger.WriteLine("Tranga", $"Loading settings {settingsFilePath}");
settings = TrangaSettings.LoadSettings(settingsFilePath); settings = TrangaSettings.LoadSettings(settingsFilePath);
}else }
else
{
settings = new TrangaSettings(downloadFolderPath, applicationFolderPath); settings = new TrangaSettings(downloadFolderPath, applicationFolderPath);
settings.version = Migrator.CurrentVersion;
}
Directory.CreateDirectory(settings.workingDirectory); Directory.CreateDirectory(settings.workingDirectory);
Directory.CreateDirectory(settings.downloadLocation); Directory.CreateDirectory(settings.downloadLocation);