Fixed: Prevent duplicate searches on list add

pull/1392/head
ta264 3 years ago
parent 0e43f67a9f
commit 735fceb074

@ -7,6 +7,7 @@ using NzbDrone.Common.Instrumentation.Extensions;
using NzbDrone.Core.Books; using NzbDrone.Core.Books;
using NzbDrone.Core.Books.Commands; using NzbDrone.Core.Books.Commands;
using NzbDrone.Core.ImportLists.Exclusions; using NzbDrone.Core.ImportLists.Exclusions;
using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource;
@ -201,19 +202,36 @@ namespace NzbDrone.Core.ImportLists
if (!existingBook.Monitored) if (!existingBook.Monitored)
{ {
_bookService.SetBookMonitored(existingBook.Id, true); _bookService.SetBookMonitored(existingBook.Id, true);
if (importList.ShouldMonitor == ImportListMonitorType.SpecificBook)
{
_commandQueueManager.Push(new BookSearchCommand(new List<int> { existingBook.Id }));
}
} }
var existingAuthor = existingBook.Author.Value; var existingAuthor = existingBook.Author.Value;
var doSearch = false;
if (importList.ShouldMonitor == ImportListMonitorType.EntireAuthor) if (importList.ShouldMonitor == ImportListMonitorType.EntireAuthor)
{ {
_bookService.SetMonitored(existingAuthor.Books.Value.Select(x => x.Id), true); if (existingAuthor.Books.Value.Any(x => !x.Monitored))
{
doSearch = true;
_bookService.SetMonitored(existingAuthor.Books.Value.Select(x => x.Id), true);
}
} }
if (!existingAuthor.Monitored) if (!existingAuthor.Monitored)
{ {
doSearch = true;
existingAuthor.Monitored = true; existingAuthor.Monitored = true;
_authorService.UpdateAuthor(existingAuthor); _authorService.UpdateAuthor(existingAuthor);
} }
if (doSearch)
{
_commandQueueManager.Push(new MissingBookSearchCommand(existingAuthor.Id));
}
} }
return; return;
@ -261,7 +279,9 @@ namespace NzbDrone.Core.ImportLists
Author = toAddAuthor, Author = toAddAuthor,
AddOptions = new AddBookOptions AddOptions = new AddBookOptions
{ {
SearchForNewBook = importList.ShouldSearch // Only search for new book for existing authors
// New author searches are triggered by SearchForMissingBooks
SearchForNewBook = importList.ShouldSearch && toAddAuthor.Id > 0
} }
}; };

Loading…
Cancel
Save