mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-05-09 05:22:09 +02:00
Fixed: Only remove missing if we send all indexers to SyncIndexers
This commit is contained in:
parent
91b23e6413
commit
4dec6dd8c4
1 changed files with 10 additions and 8 deletions
|
|
@ -35,7 +35,6 @@ public ApplicationService(IApplicationFactory applicationsFactory, IApplicationS
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
// Sync Indexers on App Add if Sync Enabled
|
||||
public void HandleAsync(ProviderAddedEvent<IApplication> message)
|
||||
{
|
||||
var appDefinition = (ApplicationDefinition)message.Definition;
|
||||
|
|
@ -84,7 +83,7 @@ public void HandleAsync(ApiKeyChangedEvent message)
|
|||
|
||||
var indexers = _indexerFactory.AllProviders().Select(i => (IndexerDefinition)i.Definition).ToList();
|
||||
|
||||
SyncIndexers(enabledApps, indexers);
|
||||
SyncIndexers(enabledApps, indexers, true);
|
||||
}
|
||||
|
||||
public void HandleAsync(ProviderBulkUpdatedEvent<IIndexer> message)
|
||||
|
|
@ -102,10 +101,10 @@ public void Execute(ApplicationIndexerSyncCommand message)
|
|||
|
||||
var indexers = _indexerFactory.AllProviders().Select(i => (IndexerDefinition)i.Definition).ToList();
|
||||
|
||||
SyncIndexers(enabledApps, indexers);
|
||||
SyncIndexers(enabledApps, indexers, true);
|
||||
}
|
||||
|
||||
private void SyncIndexers(List<IApplication> applications, List<IndexerDefinition> indexers)
|
||||
private void SyncIndexers(List<IApplication> applications, List<IndexerDefinition> indexers, bool removeRemote = false)
|
||||
{
|
||||
foreach (var app in applications)
|
||||
{
|
||||
|
|
@ -148,12 +147,15 @@ private void SyncIndexers(List<IApplication> applications, List<IndexerDefinitio
|
|||
}
|
||||
}
|
||||
|
||||
foreach (var mapping in indexerMappings)
|
||||
if (removeRemote)
|
||||
{
|
||||
if (!indexers.Any(x => x.Id == mapping.IndexerId))
|
||||
foreach (var mapping in indexerMappings)
|
||||
{
|
||||
_logger.Info("Indexer with the ID {0} was found within {1} but is no longer defined within Prowlarr, this is being removed.", mapping.IndexerId, app.Name);
|
||||
ExecuteAction(a => a.RemoveIndexer(mapping.IndexerId), app);
|
||||
if (!indexers.Any(x => x.Id == mapping.IndexerId))
|
||||
{
|
||||
_logger.Info("Indexer with the ID {0} was found within {1} but is no longer defined within Prowlarr, this is being removed.", mapping.IndexerId, app.Name);
|
||||
ExecuteAction(a => a.RemoveIndexer(mapping.IndexerId), app);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue