mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-10 11:58:19 +02:00
Improved CancellationToken usage, Added more logging to Workers, Added Code-comments (please future me, be thankful)
This commit is contained in:
@@ -207,28 +207,4 @@ public static class Tranga
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static bool AddChapterToContext((Chapter, MangaConnectorId<Chapter>) addChapter, MangaContext context, [NotNullWhen(true)] out Chapter? chapter, CancellationToken token) =>
|
||||
AddChapterToContext(addChapter.Item1, addChapter.Item2, context, out chapter, token);
|
||||
|
||||
internal static bool AddChapterToContext(Chapter addChapter, MangaConnectorId<Chapter> addChId, MangaContext context, [NotNullWhen(true)] out Chapter? chapter, CancellationToken token)
|
||||
{
|
||||
chapter = context.Chapters.Where(ch => ch.Key == addChapter.Key)
|
||||
.Include(ch => ch.ParentManga)
|
||||
.Include(ch => ch.MangaConnectorIds)
|
||||
.FirstOrDefault();
|
||||
if (chapter is not null)
|
||||
{
|
||||
chapter.MangaConnectorIds = chapter.MangaConnectorIds.UnionBy(addChapter.MangaConnectorIds, id => id.Key).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Chapters.Add(addChapter);
|
||||
chapter = addChapter;
|
||||
}
|
||||
|
||||
if (context.Sync(token).Result is { success: false })
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user