From 5586d2c10467d3017b730b7631d8add163ddc97f Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 27 Jun 2023 23:14:22 +0200 Subject: [PATCH] Connector CheckChapterIsDownloaded more Regex --- Tranga/Connector.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Tranga/Connector.cs b/Tranga/Connector.cs index 4eae7f8..88aa426 100644 --- a/Tranga/Connector.cs +++ b/Tranga/Connector.cs @@ -187,13 +187,14 @@ public abstract class Connector if (!Directory.Exists(Path.Join(settings.downloadLocation, publication.folderName))) return false; FileInfo[] archives = new DirectoryInfo(Path.Join(settings.downloadLocation, publication.folderName)).GetFiles(); - Regex chapterRex = new(@"(Vol.[0-9]*)*Ch.[0-9]+"); + Regex infoRex = new(@"(Vol.[0-9]*)?Ch.[0-9]+"); + Regex chapterInfoRex = new(@"Ch.[0-9]+"); + Regex chapterRex = new(@"[0-9]+"); if (File.Exists(newFilePath)) return true; - if (archives.FirstOrDefault(archive => - chapterRex.Match(archive.Name).Value.Split("Ch.")[^1] == chapter.chapterNumber) is { } path) + if (archives.FirstOrDefault(archive => chapterRex.Match(chapterInfoRex.Match(infoRex.Match(archive.Name).Value).Value).Value == chapter.chapterNumber) is { } path) { logger?.WriteLine(this.GetType().ToString(), "Move existing Chapter to new name."); File.Move(path.FullName, newFilePath);