From 0ad4d7ea9a69f4c26663bb012f0aa18ab29ca24a Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 17 Aug 2024 18:00:23 +0300 Subject: [PATCH] Fixed: Removing invalid statuses on provider deletion --- .../ThingiProvider/Status/ProviderStatusRepository.cs | 6 ++++++ .../ThingiProvider/Status/ProviderStatusServiceBase.cs | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core/ThingiProvider/Status/ProviderStatusRepository.cs b/src/NzbDrone.Core/ThingiProvider/Status/ProviderStatusRepository.cs index 7a2d1bc78..2748d30b5 100644 --- a/src/NzbDrone.Core/ThingiProvider/Status/ProviderStatusRepository.cs +++ b/src/NzbDrone.Core/ThingiProvider/Status/ProviderStatusRepository.cs @@ -8,6 +8,7 @@ public interface IProviderStatusRepository : IBasicRepository where TModel : ProviderStatusBase, new() { TModel FindByProviderId(int providerId); + void DeleteByProviderId(int providerId); } public class ProviderStatusRepository : BasicRepository, IProviderStatusRepository @@ -22,5 +23,10 @@ public TModel FindByProviderId(int providerId) { return Query(x => x.ProviderId == providerId).SingleOrDefault(); } + + public void DeleteByProviderId(int providerId) + { + Delete(c => c.ProviderId == providerId); + } } } diff --git a/src/NzbDrone.Core/ThingiProvider/Status/ProviderStatusServiceBase.cs b/src/NzbDrone.Core/ThingiProvider/Status/ProviderStatusServiceBase.cs index 6279c6e35..dc9f6e807 100644 --- a/src/NzbDrone.Core/ThingiProvider/Status/ProviderStatusServiceBase.cs +++ b/src/NzbDrone.Core/ThingiProvider/Status/ProviderStatusServiceBase.cs @@ -151,12 +151,7 @@ public virtual void RecordConnectionFailure(int providerId) public virtual void HandleAsync(ProviderDeletedEvent message) { - var providerStatus = _providerStatusRepository.FindByProviderId(message.ProviderId); - - if (providerStatus != null) - { - _providerStatusRepository.Delete(providerStatus); - } + _providerStatusRepository.DeleteByProviderId(message.ProviderId); } } }