Fix Seeker being scheduled when disabled (#523)

This commit is contained in:
Flaminel
2026-03-28 00:25:49 +02:00
committed by GitHub
parent a6a25de19c
commit 8183b324a0
2 changed files with 20 additions and 3 deletions

View File

@@ -140,8 +140,22 @@ public sealed class SeekerConfigController : ControllerBase
await _dataContext.SaveChangesAsync();
// Update Quartz trigger if SearchInterval changed
if (config.SearchInterval != previousInterval)
// Start/stop Seeker based on SearchEnabled toggle
if (config.SearchEnabled != previousSearchEnabled)
{
if (config.SearchEnabled)
{
_logger.LogInformation("SearchEnabled turned on, starting Seeker job");
await _jobManagementService.StartJob(JobType.Seeker, null, config.ToCronExpression());
}
else
{
_logger.LogInformation("SearchEnabled turned off, stopping Seeker job");
await _jobManagementService.StopJob(JobType.Seeker);
}
}
// Update Quartz trigger if SearchInterval changed (only while search is enabled)
else if (config.SearchEnabled && config.SearchInterval != previousInterval)
{
_logger.LogInformation("Search interval changed from {Old} to {New} minutes, updating Seeker schedule",
previousInterval, config.SearchInterval);

View File

@@ -185,7 +185,10 @@ public class BackgroundJobManager : IHostedService
public async Task RegisterSeekerJob(SeekerConfig config, CancellationToken cancellationToken = default)
{
await AddJobWithoutTrigger<SeekerJob>(cancellationToken);
await AddTriggersForJob<SeekerJob>(config.ToCronExpression(), cancellationToken);
if (config.SearchEnabled)
{
await AddTriggersForJob<SeekerJob>(config.ToCronExpression(), cancellationToken);
}
}
/// <summary>