Fix CleanupNoDownloadManga

This commit is contained in:
2025-10-02 17:56:03 +02:00
parent d5b6ff4267
commit 06555614f1

View File

@@ -24,10 +24,13 @@ public class MaintenanceController(MangaContext mangaContext) : Controller
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")] [ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
public async Task<Results<Ok, InternalServerError<string>>> CleanupNoDownloadManga() public async Task<Results<Ok, InternalServerError<string>>> CleanupNoDownloadManga()
{ {
await mangaContext.Mangas if (await mangaContext.Mangas
.Include(m => m.MangaConnectorIds) .Include(m => m.MangaConnectorIds)
.Where(m => !m.MangaConnectorIds.Any(id => id.UseForDownload)) .Where(m => !m.MangaConnectorIds.Any(id => id.UseForDownload))
.ExecuteDeleteAsync(HttpContext.RequestAborted); .ToListAsync(HttpContext.RequestAborted) is not { } remove)
return TypedResults.InternalServerError("Database error");
mangaContext.RemoveRange(remove);
if(await mangaContext.Sync(HttpContext.RequestAborted, GetType(), System.Reflection.MethodBase.GetCurrentMethod()?.Name) is { success: false } result) if(await mangaContext.Sync(HttpContext.RequestAborted, GetType(), System.Reflection.MethodBase.GetCurrentMethod()?.Name) is { success: false } result)
return TypedResults.InternalServerError(result.exceptionMessage); return TypedResults.InternalServerError(result.exceptionMessage);