mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-01-16 17:58:22 -05:00
try remove content blocker
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Common.Configuration;
|
||||
using Common.Configuration.Arr;
|
||||
using Common.Configuration.ContentBlocker;
|
||||
using Common.Configuration.DownloadCleaner;
|
||||
using Common.Configuration.DownloadClient;
|
||||
using Common.Configuration.DTOs.Arr;
|
||||
|
||||
@@ -29,12 +29,8 @@ public static class LoggingDI
|
||||
const string consoleOutputTemplate = $"[{{@t:yyyy-MM-dd HH:mm:ss.fff}} {{@l:u3}}]{jobNameTemplate}{categoryTemplate} {{@m}}\n{{@x}}";
|
||||
const string fileOutputTemplate = $"{{@t:yyyy-MM-dd HH:mm:ss.fff zzz}} [{{@l:u3}}]{jobNameTemplate}{categoryTemplate} {{@m:lj}}\n{{@x}}";
|
||||
|
||||
// Determine categories and padding sizes
|
||||
List<string> categories = ["SYSTEM", "API", "JOBS", "NOTIFICATIONS"];
|
||||
int catPadding = categories.Max(x => x.Length) + 2;
|
||||
|
||||
// Determine job name padding
|
||||
List<string> jobNames = [nameof(ContentBlocker), nameof(QueueCleaner), nameof(DownloadCleaner)];
|
||||
List<string> jobNames = [nameof(QueueCleaner), nameof(DownloadCleaner)];
|
||||
int jobPadding = jobNames.Max(x => x.Length) + 2;
|
||||
|
||||
// Determine instance name padding
|
||||
@@ -46,7 +42,7 @@ public static class LoggingDI
|
||||
InstanceType.Whisparr.ToString(),
|
||||
"SYSTEM"
|
||||
];
|
||||
int arrPadding = categoryNames.Max(x => x.Length) + 2;
|
||||
int catPadding = categoryNames.Max(x => x.Length) + 2;
|
||||
|
||||
// Apply padding values to templates
|
||||
string consoleTemplate = consoleOutputTemplate
|
||||
|
||||
@@ -38,7 +38,6 @@ public static class ServicesDI
|
||||
.AddTransient<LidarrClient>()
|
||||
.AddTransient<ArrClientFactory>()
|
||||
.AddTransient<QueueCleaner>()
|
||||
.AddTransient<ContentBlocker>()
|
||||
.AddTransient<DownloadCleaner>()
|
||||
.AddTransient<IQueueItemRemover, QueueItemRemover>()
|
||||
.AddTransient<IFilenameEvaluator, FilenameEvaluator>()
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
using Common.Configuration.ContentBlocker;
|
||||
using Common.Configuration.DownloadCleaner;
|
||||
using Common.Configuration.QueueCleaner;
|
||||
using Common.Helpers;
|
||||
using Infrastructure.Configuration;
|
||||
using Infrastructure.Verticals.ContentBlocker;
|
||||
using Infrastructure.Verticals.DownloadCleaner;
|
||||
using Infrastructure.Verticals.Jobs;
|
||||
using Infrastructure.Verticals.QueueCleaner;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Quartz;
|
||||
using Quartz.Impl.Matchers;
|
||||
using Quartz.Spi;
|
||||
|
||||
namespace Executable.Jobs;
|
||||
@@ -28,8 +24,8 @@ public class BackgroundJobManager : IHostedService
|
||||
public BackgroundJobManager(
|
||||
ISchedulerFactory schedulerFactory,
|
||||
IConfigManager configManager,
|
||||
IServiceProvider serviceProvider,
|
||||
ILogger<BackgroundJobManager> logger)
|
||||
ILogger<BackgroundJobManager> logger
|
||||
)
|
||||
{
|
||||
_schedulerFactory = schedulerFactory;
|
||||
_configManager = configManager;
|
||||
@@ -78,48 +74,11 @@ public class BackgroundJobManager : IHostedService
|
||||
}
|
||||
|
||||
// Get configurations from JSON files
|
||||
ContentBlockerConfig? contentBlockerConfig = await _configManager.GetConfigurationAsync<ContentBlockerConfig>();
|
||||
QueueCleanerConfig? queueCleanerConfig = await _configManager.GetConfigurationAsync<QueueCleanerConfig>();
|
||||
DownloadCleanerConfig? downloadCleanerConfig = await _configManager.GetConfigurationAsync<DownloadCleanerConfig>();
|
||||
QueueCleanerConfig queueCleanerConfig = await _configManager.GetConfigurationAsync<QueueCleanerConfig>();
|
||||
DownloadCleanerConfig downloadCleanerConfig = await _configManager.GetConfigurationAsync<DownloadCleanerConfig>();
|
||||
|
||||
// Add ContentBlocker job if enabled
|
||||
if (contentBlockerConfig?.Enabled == true)
|
||||
{
|
||||
await AddContentBlockerJob(contentBlockerConfig, cancellationToken);
|
||||
}
|
||||
|
||||
// Add QueueCleaner job if enabled
|
||||
if (queueCleanerConfig?.Enabled == true)
|
||||
{
|
||||
// Check if we need to chain it after ContentBlocker
|
||||
bool shouldChainAfterContentBlocker =
|
||||
contentBlockerConfig?.Enabled == true &&
|
||||
queueCleanerConfig.RunSequentially;
|
||||
|
||||
await AddQueueCleanerJob(queueCleanerConfig, shouldChainAfterContentBlocker, cancellationToken);
|
||||
}
|
||||
|
||||
// Add DownloadCleaner job if enabled
|
||||
if (downloadCleanerConfig?.Enabled == true)
|
||||
{
|
||||
await AddDownloadCleanerJob(downloadCleanerConfig, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the ContentBlocker job to the scheduler.
|
||||
/// </summary>
|
||||
public async Task AddContentBlockerJob(ContentBlockerConfig config, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (!config.Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await AddJobWithTrigger<ContentBlocker>(
|
||||
config,
|
||||
config.CronExpression,
|
||||
cancellationToken);
|
||||
await AddQueueCleanerJob(queueCleanerConfig, cancellationToken);
|
||||
await AddDownloadCleanerJob(downloadCleanerConfig, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -127,7 +86,6 @@ public class BackgroundJobManager : IHostedService
|
||||
/// </summary>
|
||||
public async Task AddQueueCleanerJob(
|
||||
QueueCleanerConfig config,
|
||||
bool chainAfterContentBlocker = false,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (!config.Enabled)
|
||||
@@ -135,28 +93,10 @@ public class BackgroundJobManager : IHostedService
|
||||
return;
|
||||
}
|
||||
|
||||
var jobKey = new JobKey(nameof(QueueCleaner));
|
||||
|
||||
// If the job should be chained after ContentBlocker, add it without a cron trigger
|
||||
if (chainAfterContentBlocker)
|
||||
{
|
||||
await AddJobWithoutTrigger<QueueCleaner>(cancellationToken);
|
||||
|
||||
// Add job listener to chain QueueCleaner after ContentBlocker
|
||||
if (_scheduler != null)
|
||||
{
|
||||
var chainListener = new JobChainingListener(nameof(ContentBlocker), nameof(QueueCleaner));
|
||||
_scheduler.ListenerManager.AddJobListener(chainListener, KeyMatcher<JobKey>.KeyEquals(new JobKey(nameof(ContentBlocker))));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add job with normal cron trigger
|
||||
await AddJobWithTrigger<QueueCleaner>(
|
||||
config,
|
||||
config.CronExpression,
|
||||
cancellationToken);
|
||||
}
|
||||
await AddJobWithTrigger<QueueCleaner>(
|
||||
config,
|
||||
config.CronExpression,
|
||||
cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user