Cover Endpoint wait for DownloadMangaCoverJob to finish if it exists

This commit is contained in:
Glax 2025-03-13 22:29:59 +01:00
parent 5f42a2d5ae
commit d278a25f16

View File

@ -108,8 +108,18 @@ public class MangaController(PgsqlContext context) : Controller
Manga? m = context.Manga.Find(MangaId); Manga? m = context.Manga.Find(MangaId);
if (m is null) if (m is null)
return NotFound(); return NotFound();
if (!System.IO.File.Exists(m.CoverFileNameInCache))
{
bool coverIsBeingDownloaded = false;
do
{
coverIsBeingDownloaded = context.Jobs.Where(j => j.JobType == JobType.DownloadMangaCoverJob).AsEnumerable()
.Any(j => j is DownloadMangaCoverJob dmcj && dmcj.MangaId == MangaId);
Thread.Sleep(100);
} while (coverIsBeingDownloaded);
if (!System.IO.File.Exists(m.CoverFileNameInCache)) if (!System.IO.File.Exists(m.CoverFileNameInCache))
return NoContent(); return NoContent();
}
Image image = Image.Load(m.CoverFileNameInCache); Image image = Image.Load(m.CoverFileNameInCache);