From c524886e6233e09fe6c7624eb6faefd79f4740f3 Mon Sep 17 00:00:00 2001 From: ta264 Date: Mon, 18 Jul 2022 23:40:27 +0100 Subject: [PATCH] Fixed: Prevent duplicate searches on list add (cherry picked from commit 735fceb0746a8bf476cac5d69bc5648c3a868219) --- .../ImportLists/ImportListSyncService.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs b/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs index 409b9a8db..6b3d114ed 100644 --- a/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs +++ b/src/NzbDrone.Core/ImportLists/ImportListSyncService.cs @@ -5,6 +5,7 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Core.ImportLists.Exclusions; +using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.MetadataSource; @@ -189,19 +190,36 @@ namespace NzbDrone.Core.ImportLists if (!existingAlbum.Monitored) { _albumService.SetAlbumMonitored(existingAlbum.Id, true); + + if (importList.ShouldMonitor == ImportListMonitorType.SpecificAlbum) + { + _commandQueueManager.Push(new AlbumSearchCommand(new List { existingAlbum.Id })); + } } var existingArtist = existingAlbum.Artist.Value; + var doSearch = false; + if (importList.ShouldMonitor == ImportListMonitorType.EntireArtist) { - _albumService.SetMonitored(existingArtist.Albums.Value.Select(x => x.Id), true); + if (existingArtist.Albums.Value.Any(x => !x.Monitored)) + { + doSearch = true; + _albumService.SetMonitored(existingArtist.Albums.Value.Select(x => x.Id), true); + } } if (!existingArtist.Monitored) { + doSearch = true; existingArtist.Monitored = true; _artistService.UpdateArtist(existingArtist); } + + if (doSearch) + { + _commandQueueManager.Push(new MissingAlbumSearchCommand(existingArtist.Id)); + } } return; @@ -240,7 +258,7 @@ namespace NzbDrone.Core.ImportLists Artist = toAddArtist, AddOptions = new AddAlbumOptions { - SearchForNewAlbum = importList.ShouldSearch + SearchForNewAlbum = importList.ShouldSearch && toAddArtist.Id > 0 } };