Remove unnecessary Attachments

This commit is contained in:
Glax 2025-05-16 21:36:24 +02:00
parent 622198a09e
commit 6258e07f20
6 changed files with 1 additions and 9 deletions

View File

@ -36,7 +36,6 @@ public class DownloadAvailableChaptersJob : Job
protected override IEnumerable<Job> RunInternal(PgsqlContext context) protected override IEnumerable<Job> RunInternal(PgsqlContext context)
{ {
context.Attach(Manga);
context.Entry(Manga).Collection<Chapter>(m => m.Chapters).Load(); context.Entry(Manga).Collection<Chapter>(m => m.Chapters).Load();
return Manga.Chapters.Select(chapter => new DownloadSingleChapterJob(chapter, this)); return Manga.Chapters.Select(chapter => new DownloadSingleChapterJob(chapter, this));
} }

View File

@ -37,7 +37,6 @@ public class DownloadMangaCoverJob : Job
protected override IEnumerable<Job> RunInternal(PgsqlContext context) protected override IEnumerable<Job> RunInternal(PgsqlContext context)
{ {
context.Attach(Manga);
try try
{ {
Manga.CoverFileNameInCache = Manga.MangaConnector.SaveCoverImageToCache(Manga); Manga.CoverFileNameInCache = Manga.MangaConnector.SaveCoverImageToCache(Manga);

View File

@ -45,8 +45,6 @@ public class DownloadSingleChapterJob : Job
protected override IEnumerable<Job> RunInternal(PgsqlContext context) protected override IEnumerable<Job> RunInternal(PgsqlContext context)
{ {
context.Attach(Chapter);
context.Attach(Chapter.ParentManga);
string[] imageUrls = Chapter.ParentManga.MangaConnector.GetChapterImageUrls(Chapter); string[] imageUrls = Chapter.ParentManga.MangaConnector.GetChapterImageUrls(Chapter);
if (imageUrls.Length < 1) if (imageUrls.Length < 1)
{ {
@ -107,8 +105,7 @@ public class DownloadSingleChapterJob : Job
Chapter.Downloaded = true; Chapter.Downloaded = true;
context.SaveChanges(); context.SaveChanges();
context.Jobs.Load(); if (context.Jobs.ToList().Any(j =>
if (context.Jobs.AsEnumerable().Any(j =>
{ {
if (j.JobType != JobType.UpdateChaptersDownloadedJob) if (j.JobType != JobType.UpdateChaptersDownloadedJob)
return false; return false;

View File

@ -40,7 +40,6 @@ public class RetrieveChaptersJob : Job
protected override IEnumerable<Job> RunInternal(PgsqlContext context) protected override IEnumerable<Job> RunInternal(PgsqlContext context)
{ {
context.Attach(Manga);
context.Entry(Manga).Collection<Chapter>(m => m.Chapters).Load(); context.Entry(Manga).Collection<Chapter>(m => m.Chapters).Load();
// This gets all chapters that are not downloaded // This gets all chapters that are not downloaded
Chapter[] allChapters = Manga.MangaConnector.GetChapters(Manga, Language); Chapter[] allChapters = Manga.MangaConnector.GetChapters(Manga, Language);

View File

@ -36,7 +36,6 @@ public class UpdateChaptersDownloadedJob : Job
protected override IEnumerable<Job> RunInternal(PgsqlContext context) protected override IEnumerable<Job> RunInternal(PgsqlContext context)
{ {
context.Attach(Manga);
context.Entry(Manga).Collection<Chapter>(m => m.Chapters).Load(); context.Entry(Manga).Collection<Chapter>(m => m.Chapters).Load();
return Manga.Chapters.Select(c => new UpdateSingleChapterDownloadedJob(c, this)); return Manga.Chapters.Select(c => new UpdateSingleChapterDownloadedJob(c, this));
} }

View File

@ -37,7 +37,6 @@ public class UpdateSingleChapterDownloadedJob : Job
protected override IEnumerable<Job> RunInternal(PgsqlContext context) protected override IEnumerable<Job> RunInternal(PgsqlContext context)
{ {
context.Attach(Chapter);
Chapter.Downloaded = Chapter.CheckDownloaded(); Chapter.Downloaded = Chapter.CheckDownloaded();
try try