mirror of
https://github.com/C9Glax/tranga.git
synced 2025-04-13 03:43:17 +02:00
Do not try and add duplicate chapters.
This commit is contained in:
parent
657ab571f9
commit
9b4baa1334
@ -24,13 +24,13 @@ public class RetrieveChaptersJob(ulong recurrenceMs, string mangaId, string? par
|
||||
Manga m = context.Manga.Find(MangaId)!;
|
||||
MangaConnector connector = context.MangaConnectors.Find(m.MangaConnectorId)!;
|
||||
// This gets all chapters that are not downloaded
|
||||
Chapter[] allNewChapters = connector.GetNewChapters(m);
|
||||
Chapter[] allNewChapters = connector.GetNewChapters(m).DistinctBy(c => c.ChapterId).ToArray();
|
||||
|
||||
// This filters out chapters that are not downloaded but already exist in the DB
|
||||
string[] chapterIds = context.Chapters.Where(chapter => chapter.ParentMangaId == m.MangaId).Select(chapter => chapter.ChapterId).ToArray();
|
||||
Chapter[] newChapters = allNewChapters.Where(chapter => !chapterIds.Contains(chapter.ChapterId)).ToArray();
|
||||
context.Chapters.AddRangeAsync(newChapters).Wait();
|
||||
context.SaveChangesAsync().Wait();
|
||||
context.Chapters.AddRange(newChapters);
|
||||
context.SaveChanges();
|
||||
|
||||
return [];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user