From 6b33075a21992accf2653d7b12637bd2f9406ca4 Mon Sep 17 00:00:00 2001 From: Flaminel Date: Wed, 26 Feb 2025 22:29:24 +0200 Subject: [PATCH] fixed merge conflicts --- .../DownloadClient/DownloadServiceFixture.cs | 2 +- .../DownloadClient/TestDownloadService.cs | 4 +-- .../DownloadClient/Deluge/DelugeService.cs | 6 ++--- .../DownloadClient/DownloadService.cs | 6 ++--- .../DownloadClient/DummyDownloadService.cs | 4 +-- .../DownloadClient/QBittorrent/QBitService.cs | 8 +++--- .../Transmission/TransmissionService.cs | 4 +-- .../Notifications/INotificationPublisher.cs | 2 ++ .../Notifications/NotificationPublisher.cs | 27 +++++++++++-------- 9 files changed, 35 insertions(+), 28 deletions(-) diff --git a/code/Infrastructure.Tests/Verticals/DownloadClient/DownloadServiceFixture.cs b/code/Infrastructure.Tests/Verticals/DownloadClient/DownloadServiceFixture.cs index 69be2eb..5b89934 100644 --- a/code/Infrastructure.Tests/Verticals/DownloadClient/DownloadServiceFixture.cs +++ b/code/Infrastructure.Tests/Verticals/DownloadClient/DownloadServiceFixture.cs @@ -57,7 +57,7 @@ public class DownloadServiceFixture : IDisposable var filenameEvaluator = Substitute.For(); var notifier = Substitute.For(); var dryRunInterceptor = Substitute.For(); - var hardlinkFileService = Substitute.For(); + var hardlinkFileService = Substitute.For(); return new TestDownloadService( Logger, diff --git a/code/Infrastructure.Tests/Verticals/DownloadClient/TestDownloadService.cs b/code/Infrastructure.Tests/Verticals/DownloadClient/TestDownloadService.cs index ebd173f..190f836 100644 --- a/code/Infrastructure.Tests/Verticals/DownloadClient/TestDownloadService.cs +++ b/code/Infrastructure.Tests/Verticals/DownloadClient/TestDownloadService.cs @@ -27,10 +27,10 @@ public class TestDownloadService : DownloadService IStriker striker, INotificationPublisher notifier, IDryRunInterceptor dryRunInterceptor, - IHardlinkFileService hardlinkFileService + IHardLinkFileService hardLinkFileService ) : base( logger, queueCleanerConfig, contentBlockerConfig, downloadCleanerConfig, cache, - filenameEvaluator, striker, notifier, dryRunInterceptor, hardlinkFileService + filenameEvaluator, striker, notifier, dryRunInterceptor, hardLinkFileService ) { } diff --git a/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeService.cs b/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeService.cs index 7db5163..b099814 100644 --- a/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeService.cs +++ b/code/Infrastructure/Verticals/DownloadClient/Deluge/DelugeService.cs @@ -35,10 +35,10 @@ public class DelugeService : DownloadService, IDelugeService IStriker striker, INotificationPublisher notifier, IDryRunInterceptor dryRunInterceptor, - IHardlinkFileService hardlinkFileService + IHardLinkFileService hardLinkFileService ) : base( logger, queueCleanerConfig, contentBlockerConfig, downloadCleanerConfig, cache, - filenameEvaluator, striker, notifier, dryRunInterceptor, hardlinkFileService + filenameEvaluator, striker, notifier, dryRunInterceptor, hardLinkFileService ) { config.Value.Validate(); @@ -252,7 +252,7 @@ public class DelugeService : DownloadService, IDelugeService continue; } - await _dryRunInterceptor.InterceptAsync(DeleteDownload, download.Hash); + await _dryRunInterceptor.InterceptAsync(DeleteDownloadAsync, download.Hash); _logger.LogInformation( "download cleaned | {reason} reached | {name}", diff --git a/code/Infrastructure/Verticals/DownloadClient/DownloadService.cs b/code/Infrastructure/Verticals/DownloadClient/DownloadService.cs index f027167..e3a7111 100644 --- a/code/Infrastructure/Verticals/DownloadClient/DownloadService.cs +++ b/code/Infrastructure/Verticals/DownloadClient/DownloadService.cs @@ -32,7 +32,7 @@ public abstract class DownloadService : IDownloadService protected readonly MemoryCacheEntryOptions _cacheOptions; protected readonly INotificationPublisher _notifier; protected readonly IDryRunInterceptor _dryRunInterceptor; - protected readonly IHardlinkFileService _hardlinkFileService; + protected readonly IHardLinkFileService _hardLinkFileService; protected DownloadService( ILogger logger, @@ -44,7 +44,7 @@ public abstract class DownloadService : IDownloadService IStriker striker, INotificationPublisher notifier, IDryRunInterceptor dryRunInterceptor, - IHardlinkFileService hardlinkFileService + IHardLinkFileService hardLinkFileService ) { _logger = logger; @@ -56,7 +56,7 @@ public abstract class DownloadService : IDownloadService _striker = striker; _notifier = notifier; _dryRunInterceptor = dryRunInterceptor; - _hardlinkFileService = hardlinkFileService; + _hardLinkFileService = hardLinkFileService; _cacheOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(StaticConfiguration.TriggerValue + Constants.CacheLimitBuffer); } diff --git a/code/Infrastructure/Verticals/DownloadClient/DummyDownloadService.cs b/code/Infrastructure/Verticals/DownloadClient/DummyDownloadService.cs index a0a942e..3d25f4c 100644 --- a/code/Infrastructure/Verticals/DownloadClient/DummyDownloadService.cs +++ b/code/Infrastructure/Verticals/DownloadClient/DummyDownloadService.cs @@ -26,10 +26,10 @@ public class DummyDownloadService : DownloadService IStriker striker, NotificationPublisher notifier, IDryRunInterceptor dryRunInterceptor, - IHardlinkFileService hardlinkFileService + IHardLinkFileService hardLinkFileService ) : base( logger, queueCleanerConfig, contentBlockerConfig, downloadCleanerConfig, - cache, filenameEvaluator, striker, notifier, dryRunInterceptor, hardlinkFileService + cache, filenameEvaluator, striker, notifier, dryRunInterceptor, hardLinkFileService ) { } diff --git a/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs b/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs index af0f5b3..44edc12 100644 --- a/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs +++ b/code/Infrastructure/Verticals/DownloadClient/QBittorrent/QBitService.cs @@ -38,10 +38,10 @@ public class QBitService : DownloadService, IQBitService IStriker striker, INotificationPublisher notifier, IDryRunInterceptor dryRunInterceptor, - IHardlinkFileService hardlinkFileService + IHardLinkFileService hardLinkFileService ) : base( logger, queueCleanerConfig, contentBlockerConfig, downloadCleanerConfig, cache, - filenameEvaluator, striker, notifier, dryRunInterceptor, hardlinkFileService + filenameEvaluator, striker, notifier, dryRunInterceptor, hardLinkFileService ) { _config = config.Value; @@ -286,7 +286,7 @@ public class QBitService : DownloadService, IQBitService continue; } - await _dryRunInterceptor.InterceptAsync(DeleteDownload, download.Hash); + await _dryRunInterceptor.InterceptAsync(DeleteDownloadAsync, download.Hash); _logger.LogInformation( "download cleaned | {reason} reached | {name}", @@ -404,7 +404,7 @@ public class QBitService : DownloadService, IQBitService continue; } - await ((QBitService)Proxy).ChangeCategory(download.Hash, _downloadCleanerConfig.NoHardLinksCategory); + await _dryRunInterceptor.InterceptAsync(ChangeCategory, download.Hash, _downloadCleanerConfig.NoHardLinksCategory); _logger.LogInformation("category changed for {name}", download.Name); diff --git a/code/Infrastructure/Verticals/DownloadClient/Transmission/TransmissionService.cs b/code/Infrastructure/Verticals/DownloadClient/Transmission/TransmissionService.cs index 11bdf37..c4c14e2 100644 --- a/code/Infrastructure/Verticals/DownloadClient/Transmission/TransmissionService.cs +++ b/code/Infrastructure/Verticals/DownloadClient/Transmission/TransmissionService.cs @@ -40,10 +40,10 @@ public class TransmissionService : DownloadService, ITransmissionService IStriker striker, INotificationPublisher notifier, IDryRunInterceptor dryRunInterceptor, - IHardlinkFileService hardlinkFileService + IHardLinkFileService hardLinkFileService ) : base( logger, queueCleanerConfig, contentBlockerConfig, downloadCleanerConfig, cache, - filenameEvaluator, striker, notifier, dryRunInterceptor, hardlinkFileService + filenameEvaluator, striker, notifier, dryRunInterceptor, hardLinkFileService ) { _config = config.Value; diff --git a/code/Infrastructure/Verticals/Notifications/INotificationPublisher.cs b/code/Infrastructure/Verticals/Notifications/INotificationPublisher.cs index 5720a33..aadadca 100644 --- a/code/Infrastructure/Verticals/Notifications/INotificationPublisher.cs +++ b/code/Infrastructure/Verticals/Notifications/INotificationPublisher.cs @@ -9,4 +9,6 @@ public interface INotificationPublisher Task NotifyQueueItemDeleted(bool removeFromClient, DeleteReason reason); Task NotifyDownloadCleaned(double ratio, TimeSpan seedingTime, string categoryName, CleanReason reason); + + Task NotifyCategoryChanged(string oldCategory, string newCategory); } \ No newline at end of file diff --git a/code/Infrastructure/Verticals/Notifications/NotificationPublisher.cs b/code/Infrastructure/Verticals/Notifications/NotificationPublisher.cs index fcdb4a8..12a2ca0 100644 --- a/code/Infrastructure/Verticals/Notifications/NotificationPublisher.cs +++ b/code/Infrastructure/Verticals/Notifications/NotificationPublisher.cs @@ -48,10 +48,10 @@ public class NotificationPublisher : INotificationPublisher switch (strikeType) { case StrikeType.Stalled: - await _dryRunInterceptor.InterceptAsync(Notify, notification.Adapt()); + await NotifyInternal(notification.Adapt()); break; case StrikeType.ImportFailed: - await _dryRunInterceptor.InterceptAsync(Notify, notification.Adapt()); + await NotifyInternal(notification.Adapt()); break; } } @@ -79,7 +79,7 @@ public class NotificationPublisher : INotificationPublisher Fields = [new() { Title = "Removed from download client?", Text = removeFromClient ? "Yes" : "No" }] }; - await _dryRunInterceptor.InterceptAsync(Notify, notification); + await NotifyInternal(notification); } public virtual async Task NotifyDownloadCleaned(double ratio, TimeSpan seedingTime, string categoryName, CleanReason reason) @@ -98,15 +98,9 @@ public class NotificationPublisher : INotificationPublisher Level = NotificationLevel.Important }; - await _dryRunInterceptor.InterceptAsync(Notify, notification); + await NotifyInternal(notification); } - - [DryRunSafeguard] - private Task Notify(T message) where T: notnull - { - return _messageBus.Publish(message); - } - + [DryRunSafeguard] public virtual async Task NotifyCategoryChanged(string oldCategory, string newCategory) { @@ -126,6 +120,17 @@ public class NotificationPublisher : INotificationPublisher await _messageBus.Publish(notification); } + private Task NotifyInternal(T message) where T: notnull + { + return _dryRunInterceptor.InterceptAsync(Notify, message); + } + + [DryRunSafeguard] + private Task Notify(T message) where T: notnull + { + return _messageBus.Publish(message); + } + private static Uri GetImageFromContext(QueueRecord record, InstanceType instanceType) => instanceType switch {