mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-14 07:17:54 +02:00
Add UpdateCoverJob.cs
Covers get updated on every pull If a Manga has no DownloadAvailableChaptersJob, Cover is removed Add endpoint POST Settings/CleanupCovers that removed covers not associated to any Manga
This commit is contained in:
@ -137,9 +137,10 @@ public class JobController(PgsqlContext context, ILog Log) : Controller
|
||||
Job updateFilesDownloaded =
|
||||
new UpdateChaptersDownloadedJob(m, record.recurrenceTimeMs, dependsOnJobs: [retrieveChapters]);
|
||||
Job downloadChapters = new DownloadAvailableChaptersJob(m, record.recurrenceTimeMs, dependsOnJobs: [retrieveChapters, updateFilesDownloaded]);
|
||||
Job UpdateCover = new UpdateCoverJob(m, record.recurrenceTimeMs, downloadChapters);
|
||||
retrieveChapters.ParentJob = downloadChapters;
|
||||
updateFilesDownloaded.ParentJob = retrieveChapters;
|
||||
return AddJobs([retrieveChapters, downloadChapters, updateFilesDownloaded]);
|
||||
return AddJobs([retrieveChapters, downloadChapters, updateFilesDownloaded, UpdateCover]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -267,4 +267,28 @@ public class SettingsController(PgsqlContext context, ILog Log) : Controller
|
||||
return StatusCode(500, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a UpdateCoverJob for all Manga
|
||||
/// </summary>
|
||||
/// <response code="200">Array of JobIds</response>
|
||||
/// <response code="500">Error during Database Operation</response>
|
||||
[HttpPost("CleanupCovers")]
|
||||
[ProducesResponseType<string[]>(Status200OK)]
|
||||
[ProducesResponseType<string>(Status500InternalServerError, "text/plain")]
|
||||
public IActionResult CleanupCovers()
|
||||
{
|
||||
try
|
||||
{
|
||||
Tranga.RemoveStaleFiles(context);
|
||||
List<UpdateCoverJob> newJobs = context.Mangas.ToList().Select(m => new UpdateCoverJob(m, 0)).ToList();
|
||||
context.Jobs.AddRange(newJobs);
|
||||
return Ok(newJobs.Select(j => j.JobId));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
return StatusCode(500, e);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user