mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-04-15 19:48:37 -04:00
Fix empty torrents (#11)
* fixed unwanted deletion of torrents in downloading metadata state * refactored jobs code * updated arr test data * updated gitignore * updated test configuration and removed dispensable files
This commit is contained in:
@@ -51,15 +51,15 @@ public static class QuartzDI
|
||||
return;
|
||||
}
|
||||
|
||||
q.AddJob<QueueCleanerJob>(opts =>
|
||||
q.AddJob<GenericJob<QueueCleaner>>(opts =>
|
||||
{
|
||||
opts.WithIdentity(nameof(QueueCleanerJob));
|
||||
opts.WithIdentity(nameof(QueueCleaner));
|
||||
});
|
||||
|
||||
q.AddTrigger(opts =>
|
||||
{
|
||||
opts.ForJob(nameof(QueueCleanerJob))
|
||||
.WithIdentity($"{nameof(QueueCleanerJob)}-trigger")
|
||||
opts.ForJob(nameof(QueueCleaner))
|
||||
.WithIdentity($"{nameof(QueueCleaner)}-trigger")
|
||||
.WithCronSchedule(trigger, x =>x.WithMisfireHandlingInstructionDoNothing());
|
||||
});
|
||||
}
|
||||
@@ -84,15 +84,15 @@ public static class QuartzDI
|
||||
return;
|
||||
}
|
||||
|
||||
q.AddJob<ContentBlockerJob>(opts =>
|
||||
q.AddJob<GenericJob<ContentBlocker>>(opts =>
|
||||
{
|
||||
opts.WithIdentity(nameof(ContentBlockerJob));
|
||||
opts.WithIdentity(nameof(ContentBlocker));
|
||||
});
|
||||
|
||||
q.AddTrigger(opts =>
|
||||
{
|
||||
opts.ForJob(nameof(ContentBlockerJob))
|
||||
.WithIdentity($"{nameof(ContentBlockerJob)}-trigger")
|
||||
opts.ForJob(nameof(ContentBlocker))
|
||||
.WithIdentity($"{nameof(ContentBlocker)}-trigger")
|
||||
.WithCronSchedule(trigger, x =>x.WithMisfireHandlingInstructionDoNothing());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ public static class ServicesDI
|
||||
services
|
||||
.AddTransient<SonarrClient>()
|
||||
.AddTransient<RadarrClient>()
|
||||
.AddTransient<QueueCleanerJob>()
|
||||
.AddTransient<ContentBlockerJob>()
|
||||
.AddTransient<QueueCleaner>()
|
||||
.AddTransient<ContentBlocker>()
|
||||
.AddTransient<FilenameEvaluator>()
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
using Infrastructure.Verticals.ContentBlocker;
|
||||
using Quartz;
|
||||
|
||||
namespace Executable.Jobs;
|
||||
|
||||
[DisallowConcurrentExecution]
|
||||
public sealed class ContentBlockerJob : IJob
|
||||
{
|
||||
private readonly ILogger<QueueCleanerJob> _logger;
|
||||
private readonly ContentBlocker _contentBlocker;
|
||||
|
||||
public ContentBlockerJob(
|
||||
ILogger<QueueCleanerJob> logger,
|
||||
ContentBlocker contentBlocker
|
||||
)
|
||||
{
|
||||
_logger = logger;
|
||||
_contentBlocker = contentBlocker;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _contentBlocker.ExecuteAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"{nameof(ContentBlockerJob)} failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
31
code/Executable/Jobs/GenericJob.cs
Normal file
31
code/Executable/Jobs/GenericJob.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Infrastructure.Verticals.Jobs;
|
||||
using Quartz;
|
||||
|
||||
namespace Executable.Jobs;
|
||||
|
||||
[DisallowConcurrentExecution]
|
||||
public sealed class GenericJob<T> : IJob
|
||||
where T : GenericHandler
|
||||
{
|
||||
private readonly ILogger<GenericJob<T>> _logger;
|
||||
private readonly T _handler;
|
||||
|
||||
|
||||
public GenericJob(ILogger<GenericJob<T>> logger, T handler)
|
||||
{
|
||||
_logger = logger;
|
||||
_handler = handler;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _handler.ExecuteAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "{name} failed", typeof(T).Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using Infrastructure.Verticals.QueueCleaner;
|
||||
using Quartz;
|
||||
|
||||
namespace Executable.Jobs;
|
||||
|
||||
[DisallowConcurrentExecution]
|
||||
public sealed class QueueCleanerJob : IJob
|
||||
{
|
||||
private readonly ILogger<QueueCleanerJob> _logger;
|
||||
private readonly QueueCleaner _queueCleaner;
|
||||
|
||||
public QueueCleanerJob(
|
||||
ILogger<QueueCleanerJob> logger,
|
||||
QueueCleaner queueCleaner
|
||||
)
|
||||
{
|
||||
_logger = logger;
|
||||
_queueCleaner = queueCleaner;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _queueCleaner.ExecuteAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"{nameof(QueueCleanerJob)} failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user