Compare commits
No commits in common. "ec8eb4094136466ff9c5908dfc3ec0247fc9fe62" and "32ab9a552ffcc0e2342e31b6f53e40196ffe7612" have entirely different histories.
ec8eb40941
...
32ab9a552f
@ -84,26 +84,24 @@ public readonly struct Chapter : IComparable
|
|||||||
/// <returns>true if chapter is present</returns>
|
/// <returns>true if chapter is present</returns>
|
||||||
internal bool CheckChapterIsDownloaded()
|
internal bool CheckChapterIsDownloaded()
|
||||||
{
|
{
|
||||||
string mangaDirectory = Path.Join(TrangaSettings.downloadLocation, parentManga.folderName);
|
if (!Directory.Exists(Path.Join(TrangaSettings.downloadLocation, parentManga.folderName)))
|
||||||
if (!Directory.Exists(mangaDirectory))
|
|
||||||
return false;
|
return false;
|
||||||
FileInfo[] archives = new DirectoryInfo(mangaDirectory).GetFiles("*.cbz");
|
FileInfo[] archives = new DirectoryInfo(Path.Join(TrangaSettings.downloadLocation, parentManga.folderName)).GetFiles().Where(file => file.Name.Split('.')[^1] == "cbz").ToArray();
|
||||||
Regex volChRex = new(@"(?:Vol(?:ume)?\.([0-9]+)\D*)?Ch(?:apter)?\.([0-9]+(?:\.[0-9]+)*)");
|
Regex volChRex = new(@"(?:Vol(?:ume)?\.([0-9]+)\D*)?Ch(?:apter)?\.([0-9]+(?:\.[0-9]+)*)");
|
||||||
|
|
||||||
Chapter t = this;
|
Chapter t = this;
|
||||||
string correctPath = GetArchiveFilePath();
|
string thisPath = GetArchiveFilePath();
|
||||||
FileInfo? archive = archives.FirstOrDefault(archive =>
|
FileInfo? archive = archives.FirstOrDefault(archive =>
|
||||||
{
|
{
|
||||||
Match m = volChRex.Match(archive.Name);
|
Match m = volChRex.Match(archive.Name);
|
||||||
/*Uncommenting this section will only allow *Version without Volume number* -> *Version with Volume number* but not the other way
|
string archiveVolNum = m.Groups[1].Success ? m.Groups[1].Value : "0";
|
||||||
if (m.Groups[1].Success)
|
string archiveChNum = m.Groups[2].Value;
|
||||||
return m.Groups[1].Value == t.volumeNumber && m.Groups[2].Value == t.chapterNumber;
|
return archiveVolNum == t.volumeNumber && archiveChNum == t.chapterNumber ||
|
||||||
else*/
|
archiveVolNum == "0" && archiveChNum == t.chapterNumber;
|
||||||
return m.Groups[2].Value == t.chapterNumber;
|
|
||||||
});
|
});
|
||||||
if(archive is not null && archive.FullName != correctPath)
|
if(archive is not null && thisPath != archive.FullName)
|
||||||
archive.MoveTo(correctPath, true);
|
archive.MoveTo(thisPath, true);
|
||||||
return (archive is not null);
|
return archive is not null;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates full file path of chapter-archive
|
/// Creates full file path of chapter-archive
|
||||||
|
Loading…
Reference in New Issue
Block a user