From cae58d620b6a6d2464475881015bc81607eb0f63 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 10 Mar 2024 20:13:35 +0200 Subject: [PATCH] New: Collection Refresh Complete Event to trigger root folder check for collections --- .../HealthCheck/Checks/DownloadClientRootFolderCheck.cs | 1 - .../HealthCheck/Checks/MovieCollectionRootFolderCheck.cs | 2 ++ .../Movies/Events/CollectionRefreshCompleteEvent.cs | 8 ++++++++ src/NzbDrone.Core/Movies/RefreshCollectionService.cs | 7 +++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/NzbDrone.Core/Movies/Events/CollectionRefreshCompleteEvent.cs diff --git a/src/NzbDrone.Core/HealthCheck/Checks/DownloadClientRootFolderCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/DownloadClientRootFolderCheck.cs index bae83d7ec..9a7fedd34 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/DownloadClientRootFolderCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/DownloadClientRootFolderCheck.cs @@ -19,7 +19,6 @@ namespace NzbDrone.Core.HealthCheck.Checks [CheckOn(typeof(ProviderDeletedEvent))] [CheckOn(typeof(ModelEvent))] [CheckOn(typeof(ModelEvent))] - public class DownloadClientRootFolderCheck : HealthCheckBase, IProvideHealthCheck { private readonly IProvideDownloadClient _downloadClientProvider; diff --git a/src/NzbDrone.Core/HealthCheck/Checks/MovieCollectionRootFolderCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/MovieCollectionRootFolderCheck.cs index 85c56fbc9..5b7c31e8b 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/MovieCollectionRootFolderCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/MovieCollectionRootFolderCheck.cs @@ -5,10 +5,12 @@ using NzbDrone.Common.Extensions; using NzbDrone.Core.Datastore.Events; using NzbDrone.Core.Localization; using NzbDrone.Core.Movies.Collections; +using NzbDrone.Core.Movies.Events; using NzbDrone.Core.RootFolders; namespace NzbDrone.Core.HealthCheck.Checks { + [CheckOn(typeof(CollectionRefreshCompleteEvent))] [CheckOn(typeof(ModelEvent))] public class MovieCollectionRootFolderCheck : HealthCheckBase { diff --git a/src/NzbDrone.Core/Movies/Events/CollectionRefreshCompleteEvent.cs b/src/NzbDrone.Core/Movies/Events/CollectionRefreshCompleteEvent.cs new file mode 100644 index 000000000..6a89ce7c9 --- /dev/null +++ b/src/NzbDrone.Core/Movies/Events/CollectionRefreshCompleteEvent.cs @@ -0,0 +1,8 @@ +using NzbDrone.Common.Messaging; + +namespace NzbDrone.Core.Movies.Events +{ + public class CollectionRefreshCompleteEvent : IEvent + { + } +} diff --git a/src/NzbDrone.Core/Movies/RefreshCollectionService.cs b/src/NzbDrone.Core/Movies/RefreshCollectionService.cs index 69e93e72d..c8b9d1803 100644 --- a/src/NzbDrone.Core/Movies/RefreshCollectionService.cs +++ b/src/NzbDrone.Core/Movies/RefreshCollectionService.cs @@ -6,9 +6,11 @@ using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Core.Exceptions; using NzbDrone.Core.ImportLists.ImportExclusions; using NzbDrone.Core.Messaging.Commands; +using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Movies.Collections; using NzbDrone.Core.Movies.Commands; +using NzbDrone.Core.Movies.Events; namespace NzbDrone.Core.Movies { @@ -20,6 +22,7 @@ namespace NzbDrone.Core.Movies private readonly IMovieMetadataService _movieMetadataService; private readonly IAddMovieService _addMovieService; private readonly IImportExclusionsService _importExclusionService; + private readonly IEventAggregator _eventAggregator; private readonly Logger _logger; @@ -29,6 +32,7 @@ namespace NzbDrone.Core.Movies IMovieMetadataService movieMetadataService, IAddMovieService addMovieService, IImportExclusionsService importExclusionsService, + IEventAggregator eventAggregator, Logger logger) { _movieInfo = movieInfo; @@ -37,6 +41,7 @@ namespace NzbDrone.Core.Movies _movieMetadataService = movieMetadataService; _addMovieService = addMovieService; _importExclusionService = importExclusionsService; + _eventAggregator = eventAggregator; _logger = logger; } @@ -179,6 +184,8 @@ namespace NzbDrone.Core.Movies } } } + + _eventAggregator.PublishEvent(new CollectionRefreshCompleteEvent()); } } }