1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2025-01-02 21:15:05 +00:00

Fixed: Removing invalid statuses on provider deletion

This commit is contained in:
Bogdan 2024-08-17 18:00:23 +03:00
parent 916fbb2a69
commit 36e67fdc2e
2 changed files with 7 additions and 6 deletions

View file

@ -8,6 +8,7 @@ public interface IProviderStatusRepository<TModel> : IBasicRepository<TModel>
where TModel : ProviderStatusBase, new() where TModel : ProviderStatusBase, new()
{ {
TModel FindByProviderId(int providerId); TModel FindByProviderId(int providerId);
void DeleteByProviderId(int providerId);
} }
public class ProviderStatusRepository<TModel> : BasicRepository<TModel>, IProviderStatusRepository<TModel> public class ProviderStatusRepository<TModel> : BasicRepository<TModel>, IProviderStatusRepository<TModel>
@ -22,5 +23,10 @@ public TModel FindByProviderId(int providerId)
{ {
return Query(c => c.ProviderId == providerId).SingleOrDefault(); return Query(c => c.ProviderId == providerId).SingleOrDefault();
} }
public void DeleteByProviderId(int providerId)
{
Delete(c => c.ProviderId == providerId);
}
} }
} }

View file

@ -151,12 +151,7 @@ public virtual void RecordConnectionFailure(int providerId)
public virtual void HandleAsync(ProviderDeletedEvent<TProvider> message) public virtual void HandleAsync(ProviderDeletedEvent<TProvider> message)
{ {
var providerStatus = _providerStatusRepository.FindByProviderId(message.ProviderId); _providerStatusRepository.DeleteByProviderId(message.ProviderId);
if (providerStatus != null)
{
_providerStatusRepository.Delete(providerStatus);
}
} }
} }
} }