From d278a25f16ea453df527b81de9a7f764d1bd46cd Mon Sep 17 00:00:00 2001 From: Glax Date: Thu, 13 Mar 2025 22:29:59 +0100 Subject: [PATCH] Cover Endpoint wait for DownloadMangaCoverJob to finish if it exists --- API/Controllers/MangaController.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/API/Controllers/MangaController.cs b/API/Controllers/MangaController.cs index 77625a7..c45e374 100644 --- a/API/Controllers/MangaController.cs +++ b/API/Controllers/MangaController.cs @@ -109,7 +109,17 @@ public class MangaController(PgsqlContext context) : Controller if (m is null) return NotFound(); if (!System.IO.File.Exists(m.CoverFileNameInCache)) - return NoContent(); + { + 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)) + return NoContent(); + } Image image = Image.Load(m.CoverFileNameInCache);