From 420013f07b71e21863c598535e553baa4b3daaa7 Mon Sep 17 00:00:00 2001 From: Glax Date: Wed, 30 Oct 2024 18:23:14 +0100 Subject: [PATCH] Delete chapterMarkers if the file doesn't exist anymore. --- Tranga/Chapter.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Tranga/Chapter.cs b/Tranga/Chapter.cs index 6e40c6b..928591a 100644 --- a/Tranga/Chapter.cs +++ b/Tranga/Chapter.cs @@ -89,13 +89,15 @@ public readonly struct Chapter : IComparable return false; FileInfo? mangaArchive = null; string markerPath = Path.Join(mangaDirectory, $".{id}"); - if (this.id is not null - && File.Exists(markerPath) - && File.Exists(File.ReadAllText(markerPath))) + if (this.id is not null && File.Exists(markerPath)) { - mangaArchive = new FileInfo(File.ReadAllText(markerPath)); + if(File.Exists(File.ReadAllText(markerPath))) + mangaArchive = new FileInfo(File.ReadAllText(markerPath)); + else + File.Delete(markerPath); } - else + + if(mangaArchive is null) { FileInfo[] archives = new DirectoryInfo(mangaDirectory).GetFiles("*.cbz"); Regex volChRex = new(@"(?:Vol(?:ume)?\.([0-9]+)\D*)?Ch(?:apter)?\.([0-9]+(?:\.[0-9]+)*)"); @@ -110,6 +112,7 @@ public readonly struct Chapter : IComparable return m.Groups[2].Value == t.chapterNumber; }); } + string correctPath = GetArchiveFilePath(); if(mangaArchive is not null && mangaArchive.FullName != correctPath) mangaArchive.MoveTo(correctPath, true);