Created Method to check wether file is already downloaded.

Using this method when running TaskExecutor.UpdateChapters to get a list of all chapters that have not yet been downloaded.
This commit is contained in:
glax 2023-05-20 01:30:23 +02:00
parent 08e0fe7c71
commit 9d583b284a
3 changed files with 12 additions and 4 deletions

View File

@ -77,6 +77,16 @@ public abstract class Connector
);
return comicInfo.ToString();
}
public bool ChapterIsDownloaded(Publication publication, Chapter chapter)
{
return File.Exists(CreateFullFilepath(publication, chapter));
}
protected string CreateFullFilepath(Publication publication, Chapter chapter)
{
return Path.Join(downloadLocation, publication.folderName, chapter.fileName);
}
/// <summary>
/// Downloads Image from URL and saves it to the given path(incl. fileName)

View File

@ -201,7 +201,7 @@ public class MangaDex : Connector
File.WriteAllText(comicInfoPath, CreateComicInfo(publication, chapter));
//Download Chapter-Images
DownloadChapterImages(imageUrls.ToArray(), Path.Join(downloadLocation, publication.folderName, chapter.fileName), this.downloadClient, comicInfoPath);
DownloadChapterImages(imageUrls.ToArray(), CreateFullFilepath(publication, chapter), downloadClient, comicInfoPath);
}
public override void DownloadCover(Publication publication)

View File

@ -96,11 +96,9 @@ public static class TaskExecutor
if (!chapterCollection.ContainsKey(publication))
return newChaptersList;
List<Chapter> currentChapters = chapterCollection[publication];
Chapter[] newChapters = connector.GetChapters(publication, language);
newChaptersList = newChapters.Where(nChapter => !connector.ChapterIsDownloaded(publication, nChapter)).ToList();
newChaptersList = newChapters.ToList()
.ExceptBy(currentChapters.Select(cChapter => cChapter.url), nChapter => nChapter.url).ToList();
return newChaptersList;
}
}