diff --git a/Tranga/Connector.cs b/Tranga/Connector.cs index 31fd6a3..1d24e63 100644 --- a/Tranga/Connector.cs +++ b/Tranga/Connector.cs @@ -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); + } /// /// Downloads Image from URL and saves it to the given path(incl. fileName) diff --git a/Tranga/Connectors/MangaDex.cs b/Tranga/Connectors/MangaDex.cs index 050e3b8..554f5a8 100644 --- a/Tranga/Connectors/MangaDex.cs +++ b/Tranga/Connectors/MangaDex.cs @@ -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) diff --git a/Tranga/TaskExecutor.cs b/Tranga/TaskExecutor.cs index 1021a8d..1670ed2 100644 --- a/Tranga/TaskExecutor.cs +++ b/Tranga/TaskExecutor.cs @@ -96,11 +96,9 @@ public static class TaskExecutor if (!chapterCollection.ContainsKey(publication)) return newChaptersList; - List 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; } } \ No newline at end of file