Improved CancellationToken usage, Added more logging to Workers, Added Code-comments (please future me, be thankful)

This commit is contained in:
2025-09-02 19:36:06 +02:00
parent 6fa166363a
commit 55f04710a7
16 changed files with 235 additions and 121 deletions

View File

@@ -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;
}
}