Skip to content

Commit

Permalink
Fixed: Prevent duplicate searches on list add
Browse files Browse the repository at this point in the history
(cherry picked from commit 735fceb0746a8bf476cac5d69bc5648c3a868219)
  • Loading branch information
ta264 committed Aug 3, 2022
1 parent 70ae0c9 commit c524886
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/NzbDrone.Core/ImportLists/ImportListSyncService.cs
Expand Up @@ -5,6 +5,7 @@
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;
Expand Down Expand Up @@ -189,19 +190,36 @@ private void ProcessAlbumReport(ImportListDefinition importList, ImportListItemI
if (!existingAlbum.Monitored)
{
_albumService.SetAlbumMonitored(existingAlbum.Id, true);

if (importList.ShouldMonitor == ImportListMonitorType.SpecificAlbum)
{
_commandQueueManager.Push(new AlbumSearchCommand(new List<int> { 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;
Expand Down Expand Up @@ -240,7 +258,7 @@ private void ProcessAlbumReport(ImportListDefinition importList, ImportListItemI
Artist = toAddArtist,
AddOptions = new AddAlbumOptions
{
SearchForNewAlbum = importList.ShouldSearch
SearchForNewAlbum = importList.ShouldSearch && toAddArtist.Id > 0
}
};

Expand Down

0 comments on commit c524886

Please sign in to comment.