mirror of
https://github.com/C9Glax/tranga.git
synced 2025-04-12 19:36:08 +02:00
Do not delay LatestChapterAvailable/Downloaded Requests if we have a number (which will still be updated)
Some checks are pending
Docker Image CI / build (push) Waiting to run
Some checks are pending
Docker Image CI / build (push) Waiting to run
This commit is contained in:
parent
f10c478cab
commit
cef3b24efd
@ -115,13 +115,13 @@ public class MangaController(PgsqlContext context) : Controller
|
|||||||
List<Job> coverDownloadJobs = context.Jobs.Where(j => j.JobType == JobType.DownloadMangaCoverJob).ToList();
|
List<Job> coverDownloadJobs = context.Jobs.Where(j => j.JobType == JobType.DownloadMangaCoverJob).ToList();
|
||||||
if (coverDownloadJobs.Any(j => j is DownloadMangaCoverJob dmc && dmc.MangaId == MangaId))
|
if (coverDownloadJobs.Any(j => j is DownloadMangaCoverJob dmc && dmc.MangaId == MangaId))
|
||||||
{
|
{
|
||||||
Response.Headers.Add("Retry-After", $"{TrangaSettings.startNewJobTimeoutMs * coverDownloadJobs.Count() / 1000:D}");
|
Response.Headers.Add("Retry-After", $"{TrangaSettings.startNewJobTimeoutMs * coverDownloadJobs.Count() * 2 / 1000:D}");
|
||||||
return StatusCode(Status503ServiceUnavailable, TrangaSettings.startNewJobTimeoutMs * coverDownloadJobs.Count() / 1000);
|
return StatusCode(Status503ServiceUnavailable, TrangaSettings.startNewJobTimeoutMs * coverDownloadJobs.Count() * 2 / 1000);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!System.IO.File.Exists(m.CoverFileNameInCache))
|
|
||||||
return NoContent();
|
|
||||||
Image image = Image.Load(m.CoverFileNameInCache);
|
Image image = Image.Load(m.CoverFileNameInCache);
|
||||||
|
|
||||||
if (width is { } w && height is { } h)
|
if (width is { } w && height is { } h)
|
||||||
@ -227,17 +227,18 @@ public class MangaController(PgsqlContext context) : Controller
|
|||||||
Manga? m = context.Mangas.Find(MangaId);
|
Manga? m = context.Mangas.Find(MangaId);
|
||||||
if (m is null)
|
if (m is null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
List<Job> retrieveChapterJobs = context.Jobs.Where(j => j.JobType == JobType.RetrieveChaptersJob).ToList();
|
|
||||||
if (retrieveChapterJobs.Any(j => j is RetrieveChaptersJob rcj && rcj.MangaId == MangaId))
|
|
||||||
{
|
|
||||||
Response.Headers.Add("Retry-After", $"{TrangaSettings.startNewJobTimeoutMs * retrieveChapterJobs.Count() / 1000:D}");
|
|
||||||
return StatusCode(Status503ServiceUnavailable, TrangaSettings.startNewJobTimeoutMs * retrieveChapterJobs.Count() / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Chapter> chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId).ToList();
|
List<Chapter> chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId).ToList();
|
||||||
if (chapters.Count == 0)
|
if (chapters.Count == 0)
|
||||||
return NoContent();
|
{
|
||||||
|
List<Job> retrieveChapterJobs = context.Jobs.Where(j => j.JobType == JobType.RetrieveChaptersJob).ToList();
|
||||||
|
if (retrieveChapterJobs.Any(j => j is RetrieveChaptersJob rcj && rcj.MangaId == MangaId))
|
||||||
|
{
|
||||||
|
Response.Headers.Add("Retry-After", $"{TrangaSettings.startNewJobTimeoutMs * retrieveChapterJobs.Count() * 2 / 1000:D}");
|
||||||
|
return StatusCode(Status503ServiceUnavailable, TrangaSettings.startNewJobTimeoutMs * retrieveChapterJobs.Count() * 2/ 1000);
|
||||||
|
}else
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
Chapter? max = chapters.Max();
|
Chapter? max = chapters.Max();
|
||||||
if (max is null)
|
if (max is null)
|
||||||
@ -267,16 +268,18 @@ public class MangaController(PgsqlContext context) : Controller
|
|||||||
if (m is null)
|
if (m is null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
List<Job> retrieveChapterJobs = context.Jobs.Where(j => j.JobType == JobType.RetrieveChaptersJob).ToList();
|
|
||||||
if (retrieveChapterJobs.Any(j => j is RetrieveChaptersJob rcj && rcj.MangaId == MangaId))
|
|
||||||
{
|
|
||||||
Response.Headers.Add("Retry-After", $"{TrangaSettings.startNewJobTimeoutMs * retrieveChapterJobs.Count() / 1000:D}");
|
|
||||||
return StatusCode(Status503ServiceUnavailable, TrangaSettings.startNewJobTimeoutMs * retrieveChapterJobs.Count() / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Chapter> chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId && c.Downloaded == true).ToList();
|
List<Chapter> chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId && c.Downloaded == true).ToList();
|
||||||
if (chapters.Count == 0)
|
if (chapters.Count == 0)
|
||||||
return NoContent();
|
{
|
||||||
|
List<Job> retrieveChapterJobs = context.Jobs.Where(j => j.JobType == JobType.RetrieveChaptersJob).ToList();
|
||||||
|
if (retrieveChapterJobs.Any(j => j is RetrieveChaptersJob rcj && rcj.MangaId == MangaId))
|
||||||
|
{
|
||||||
|
Response.Headers.Add("Retry-After", $"{TrangaSettings.startNewJobTimeoutMs * retrieveChapterJobs.Count() * 2 / 1000:D}");
|
||||||
|
return StatusCode(Status503ServiceUnavailable, TrangaSettings.startNewJobTimeoutMs * retrieveChapterJobs.Count() * 2 / 1000);
|
||||||
|
}else
|
||||||
|
return NoContent();
|
||||||
|
}
|
||||||
|
|
||||||
Chapter? max = chapters.Max();
|
Chapter? max = chapters.Max();
|
||||||
if (max is null)
|
if (max is null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user