diff --git a/code/Executable/Controllers/ConfigurationController.cs b/code/Executable/Controllers/ConfigurationController.cs
index f7519797..a686e10b 100644
--- a/code/Executable/Controllers/ConfigurationController.cs
+++ b/code/Executable/Controllers/ConfigurationController.cs
@@ -169,6 +169,28 @@ public class ConfigurationController : ControllerBase
await _jobManagementService.StopJob(JobType.QueueCleaner);
}
}
+
+ ///
+ /// Updates the DownloadCleaner job schedule based on configuration changes
+ ///
+ /// The DownloadCleaner configuration
+ private async Task UpdateDownloadCleanerJobSchedule(DownloadCleanerConfig config)
+ {
+ if (config.Enabled)
+ {
+ // If the job is enabled, update its schedule with the configured cron expression
+ _logger.LogInformation("DownloadCleaner is enabled, updating job schedule with cron expression: {CronExpression}", config.CronExpression);
+
+ // Create a Quartz job schedule with the cron expression
+ await _jobManagementService.StartJob(JobType.DownloadCleaner, null, config.CronExpression);
+ }
+ else
+ {
+ // If the job is disabled, stop it
+ _logger.LogInformation("DownloadCleaner is disabled, stopping the job");
+ await _jobManagementService.StopJob(JobType.DownloadCleaner);
+ }
+ }
[HttpPut("content_blocker")]
public async Task UpdateContentBlockerConfig([FromBody] ContentBlockerConfigUpdateDto dto)
@@ -211,6 +233,9 @@ public class ConfigurationController : ControllerBase
return StatusCode(500, "Failed to save DownloadCleaner configuration");
}
+ // Update the scheduler based on configuration changes
+ await UpdateDownloadCleanerJobSchedule(config);
+
return Ok(new { Message = "DownloadCleaner configuration updated successfully" });
}