diff --git a/src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs b/src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs index f86566c6e..3469ba033 100644 --- a/src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs +++ b/src/NzbDrone.Core/AuthorStats/AuthorStatisticsService.cs @@ -15,12 +15,14 @@ public interface IAuthorStatisticsService } public class AuthorStatisticsService : IAuthorStatisticsService, + IHandle, IHandle, IHandle, IHandle, IHandle, IHandle, IHandle, + IHandle, IHandle { private readonly IAuthorStatisticsRepository _authorStatisticsRepository; @@ -68,6 +70,13 @@ private AuthorStatistics MapAuthorStatistics(List bookStatistics return authorStatistics; } + [EventHandleOrder(EventHandleOrder.First)] + public void Handle(AuthorAddedEvent message) + { + _cache.Remove("AllAuthors"); + _cache.Remove(message.Author.Id.ToString()); + } + [EventHandleOrder(EventHandleOrder.First)] public void Handle(AuthorUpdatedEvent message) { @@ -110,6 +119,13 @@ public void Handle(BookEditedEvent message) _cache.Remove(message.Book.AuthorId.ToString()); } + [EventHandleOrder(EventHandleOrder.First)] + public void Handle(BookUpdatedEvent message) + { + _cache.Remove("AllAuthors"); + _cache.Remove(message.Book.AuthorId.ToString()); + } + [EventHandleOrder(EventHandleOrder.First)] public void Handle(BookFileDeletedEvent message) { diff --git a/src/NzbDrone.Core/Books/Services/RefreshBookService.cs b/src/NzbDrone.Core/Books/Services/RefreshBookService.cs index b222d7bcb..c5478c7e6 100644 --- a/src/NzbDrone.Core/Books/Services/RefreshBookService.cs +++ b/src/NzbDrone.Core/Books/Services/RefreshBookService.cs @@ -14,6 +14,7 @@ using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.MetadataSource; +using NzbDrone.Core.RootFolders; namespace NzbDrone.Core.Books { @@ -30,6 +31,7 @@ public class RefreshBookService : RefreshEntityServiceBase, { private readonly IBookService _bookService; private readonly IAuthorService _authorService; + private readonly IRootFolderService _rootFolderService; private readonly IAddAuthorService _addAuthorService; private readonly IEditionService _editionService; private readonly IProvideAuthorInfo _authorInfo; @@ -44,6 +46,7 @@ public class RefreshBookService : RefreshEntityServiceBase, public RefreshBookService(IBookService bookService, IAuthorService authorService, + IRootFolderService rootFolderService, IAddAuthorService addAuthorService, IEditionService editionService, IAuthorMetadataService authorMetadataService, @@ -60,6 +63,7 @@ public RefreshBookService(IBookService bookService, { _bookService = bookService; _authorService = authorService; + _rootFolderService = rootFolderService; _addAuthorService = addAuthorService; _editionService = editionService; _authorInfo = authorInfo; @@ -142,7 +146,7 @@ protected override void EnsureNewParent(Book local, Book remote) Metadata = remote.AuthorMetadata.Value, MetadataProfileId = oldAuthor.MetadataProfileId, QualityProfileId = oldAuthor.QualityProfileId, - RootFolderPath = oldAuthor.RootFolderPath, + RootFolderPath = _rootFolderService.GetBestRootFolderPath(oldAuthor.Path), Monitored = oldAuthor.Monitored, Tags = oldAuthor.Tags }; diff --git a/src/Readarr.Api.V1/Author/AuthorController.cs b/src/Readarr.Api.V1/Author/AuthorController.cs index 0d859f6e0..0d58356c0 100644 --- a/src/Readarr.Api.V1/Author/AuthorController.cs +++ b/src/Readarr.Api.V1/Author/AuthorController.cs @@ -29,6 +29,7 @@ public class AuthorController : RestControllerWithSignalR, IHandle, IHandle, + IHandle, IHandle, IHandle, IHandle, @@ -255,6 +256,12 @@ public void Handle(BookFileDeletedEvent message) BroadcastResourceChange(ModelAction.Updated, GetAuthorResource(message.BookFile.Author.Value)); } + [NonAction] + public void Handle(AuthorAddedEvent message) + { + BroadcastResourceChange(ModelAction.Updated, GetAuthorResource(message.Author)); + } + [NonAction] public void Handle(AuthorUpdatedEvent message) {