mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2025-12-30 01:18:36 -05:00
Compare commits
5 Commits
main
...
fix_deluge
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8f438d3e7 | ||
|
|
3916843cee | ||
|
|
4175a8b69b | ||
|
|
4593a13e74 | ||
|
|
f5335feca7 |
@@ -55,8 +55,8 @@ public static class MainDI
|
||||
{
|
||||
e.ConfigureConsumer<DownloadRemoverConsumer<SearchItem>>(context);
|
||||
e.ConfigureConsumer<DownloadRemoverConsumer<SeriesSearchItem>>(context);
|
||||
e.ConcurrentMessageLimit = 2;
|
||||
e.PrefetchCount = 2;
|
||||
e.ConcurrentMessageLimit = 1;
|
||||
e.PrefetchCount = 1;
|
||||
});
|
||||
|
||||
cfg.ReceiveEndpoint("download-hunter-queue", e =>
|
||||
|
||||
@@ -5,6 +5,7 @@ using Cleanuparr.Infrastructure.Features.Arr;
|
||||
using Cleanuparr.Infrastructure.Features.Arr.Interfaces;
|
||||
using Cleanuparr.Infrastructure.Features.Context;
|
||||
using Cleanuparr.Infrastructure.Features.DownloadClient;
|
||||
using Cleanuparr.Infrastructure.Features.DownloadClient.Deluge;
|
||||
using Cleanuparr.Infrastructure.Features.Jobs;
|
||||
using Cleanuparr.Infrastructure.Features.MalwareBlocker;
|
||||
using Cleanuparr.Infrastructure.Helpers;
|
||||
@@ -147,35 +148,37 @@ public sealed class MalwareBlocker : GenericHandler
|
||||
ContextProvider.Set(nameof(QueueRecord), record);
|
||||
|
||||
BlockFilesResult result = new();
|
||||
IDownloadService? downloadService = null;
|
||||
|
||||
if (record.Protocol is "torrent")
|
||||
{
|
||||
var torrentClients = downloadServices
|
||||
var torrentServices = downloadServices
|
||||
.Where(x => x.ClientConfig.Type is DownloadClientType.Torrent)
|
||||
.ToList();
|
||||
|
||||
_logger.LogDebug("searching unwanted files for {title}", record.Title);
|
||||
|
||||
if (torrentClients.Count > 0)
|
||||
if (torrentServices.Count > 0)
|
||||
{
|
||||
// Check each download client for the download item
|
||||
foreach (var downloadService in torrentClients)
|
||||
foreach (var torrentService in torrentServices)
|
||||
{
|
||||
try
|
||||
{
|
||||
// stalled download check
|
||||
result = await downloadService
|
||||
result = await torrentService
|
||||
.BlockUnwantedFilesAsync(record.DownloadId, ignoredDownloads);
|
||||
|
||||
if (result.Found)
|
||||
{
|
||||
downloadService = torrentService;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error checking download {dName} with download client {cName}",
|
||||
record.Title, downloadService.ClientConfig.Name);
|
||||
record.Title, torrentService.ClientConfig.Name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +207,11 @@ public sealed class MalwareBlocker : GenericHandler
|
||||
removeFromClient = false;
|
||||
}
|
||||
|
||||
if (downloadService is DelugeService delugeService)
|
||||
{
|
||||
await delugeService.PauseAsync(record.DownloadId);
|
||||
}
|
||||
|
||||
await PublishQueueItemRemoveRequest(
|
||||
downloadRemovalKey,
|
||||
instanceType,
|
||||
|
||||
@@ -5,6 +5,7 @@ using Cleanuparr.Infrastructure.Features.Arr;
|
||||
using Cleanuparr.Infrastructure.Features.Arr.Interfaces;
|
||||
using Cleanuparr.Infrastructure.Features.Context;
|
||||
using Cleanuparr.Infrastructure.Features.DownloadClient;
|
||||
using Cleanuparr.Infrastructure.Features.DownloadClient.Deluge;
|
||||
using Cleanuparr.Infrastructure.Features.Jobs;
|
||||
using Cleanuparr.Infrastructure.Helpers;
|
||||
using Cleanuparr.Persistence;
|
||||
@@ -107,33 +108,35 @@ public sealed class QueueCleaner : GenericHandler
|
||||
ContextProvider.Set(nameof(QueueRecord), record);
|
||||
|
||||
DownloadCheckResult downloadCheckResult = new();
|
||||
IDownloadService? downloadService = null;
|
||||
|
||||
if (record.Protocol.Contains("torrent", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var torrentClients = downloadServices
|
||||
var torrentServices = downloadServices
|
||||
.Where(x => x.ClientConfig.Type is DownloadClientType.Torrent)
|
||||
.ToList();
|
||||
|
||||
if (torrentClients.Count > 0)
|
||||
if (torrentServices.Count > 0)
|
||||
{
|
||||
// Check each download client for the download item
|
||||
foreach (var downloadService in torrentClients)
|
||||
foreach (var torrentService in torrentServices)
|
||||
{
|
||||
try
|
||||
{
|
||||
// stalled download check
|
||||
downloadCheckResult = await downloadService
|
||||
downloadCheckResult = await torrentService
|
||||
.ShouldRemoveFromArrQueueAsync(record.DownloadId, ignoredDownloads);
|
||||
|
||||
if (downloadCheckResult.Found)
|
||||
{
|
||||
downloadService = torrentService;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error checking download {dName} with download client {cName}",
|
||||
record.Title, downloadService.ClientConfig.Name);
|
||||
record.Title, torrentService.ClientConfig.Name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +186,11 @@ public sealed class QueueCleaner : GenericHandler
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadService is DelugeService delugeService)
|
||||
{
|
||||
await delugeService.PauseAsync(record.DownloadId);
|
||||
}
|
||||
|
||||
await PublishQueueItemRemoveRequest(
|
||||
downloadRemovalKey,
|
||||
instanceType,
|
||||
|
||||
@@ -236,4 +236,9 @@ public sealed class DelugeClient
|
||||
{
|
||||
await SendRequest<DelugeResponse<object>>("label.set_torrent", hash, newLabel);
|
||||
}
|
||||
|
||||
public async Task PauseAsync(string hash)
|
||||
{
|
||||
await SendRequest<DelugeResponse<object>>("core.pause_torrent", hash);
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,15 @@ public partial class DelugeService : DownloadService, IDelugeService
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task PauseAsync(string hash)
|
||||
{
|
||||
hash = hash.ToLowerInvariant();
|
||||
|
||||
_logger.LogDebug("Pausing torrent {hash} in Deluge client {name}", hash, _downloadClientConfig.Name);
|
||||
|
||||
await _client.PauseAsync(hash);
|
||||
}
|
||||
|
||||
public override async Task<HealthCheckResult> HealthCheckAsync()
|
||||
{
|
||||
|
||||
@@ -60,6 +60,8 @@ public sealed class QueueItemRemover : IQueueItemRemover
|
||||
SearchItem = request.SearchItem,
|
||||
Record = request.Record
|
||||
});
|
||||
|
||||
await Task.Delay(30 * 1000);
|
||||
}
|
||||
catch (HttpRequestException exception)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user