From 36e67fdc2e6c91c9cc28f2a87774a27b9eb0b6d1 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 de947ad21..366f42bdc 100644 --- a/src/NzbDrone.Core/ThingiProvider/Status/ProviderStatusRepository.cs +++ b/src/NzbDrone.Core/ThingiProvider/Status/ProviderStatusRepository.cs @@ -8,6 +8,7 @@ namespace NzbDrone.Core.ThingiProvider.Status where TModel : ProviderStatusBase, new() { TModel FindByProviderId(int providerId); + void DeleteByProviderId(int providerId); } public class ProviderStatusRepository : BasicRepository, IProviderStatusRepository @@ -22,5 +23,10 @@ namespace NzbDrone.Core.ThingiProvider.Status { return Query(c => c.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 @@ namespace NzbDrone.Core.ThingiProvider.Status public virtual void HandleAsync(ProviderDeletedEvent message) { - var providerStatus = _providerStatusRepository.FindByProviderId(message.ProviderId); - - if (providerStatus != null) - { - _providerStatusRepository.Delete(providerStatus); - } + _providerStatusRepository.DeleteByProviderId(message.ProviderId); } } }