mirror of
https://github.com/Readarr/Readarr
synced 2026-05-09 05:21:41 +02:00
Fixed: Add missing author when a book's author changes in metadata
Fixes READARR-VH
This commit is contained in:
parent
c0c0847963
commit
b3f99d8c20
3 changed files with 28 additions and 1 deletions
|
|
@ -15,12 +15,14 @@ public interface IAuthorStatisticsService
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AuthorStatisticsService : IAuthorStatisticsService,
|
public class AuthorStatisticsService : IAuthorStatisticsService,
|
||||||
|
IHandle<AuthorAddedEvent>,
|
||||||
IHandle<AuthorUpdatedEvent>,
|
IHandle<AuthorUpdatedEvent>,
|
||||||
IHandle<AuthorDeletedEvent>,
|
IHandle<AuthorDeletedEvent>,
|
||||||
IHandle<BookAddedEvent>,
|
IHandle<BookAddedEvent>,
|
||||||
IHandle<BookDeletedEvent>,
|
IHandle<BookDeletedEvent>,
|
||||||
IHandle<BookImportedEvent>,
|
IHandle<BookImportedEvent>,
|
||||||
IHandle<BookEditedEvent>,
|
IHandle<BookEditedEvent>,
|
||||||
|
IHandle<BookUpdatedEvent>,
|
||||||
IHandle<BookFileDeletedEvent>
|
IHandle<BookFileDeletedEvent>
|
||||||
{
|
{
|
||||||
private readonly IAuthorStatisticsRepository _authorStatisticsRepository;
|
private readonly IAuthorStatisticsRepository _authorStatisticsRepository;
|
||||||
|
|
@ -68,6 +70,13 @@ private AuthorStatistics MapAuthorStatistics(List<BookStatistics> bookStatistics
|
||||||
return authorStatistics;
|
return authorStatistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[EventHandleOrder(EventHandleOrder.First)]
|
||||||
|
public void Handle(AuthorAddedEvent message)
|
||||||
|
{
|
||||||
|
_cache.Remove("AllAuthors");
|
||||||
|
_cache.Remove(message.Author.Id.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
[EventHandleOrder(EventHandleOrder.First)]
|
[EventHandleOrder(EventHandleOrder.First)]
|
||||||
public void Handle(AuthorUpdatedEvent message)
|
public void Handle(AuthorUpdatedEvent message)
|
||||||
{
|
{
|
||||||
|
|
@ -110,6 +119,13 @@ public void Handle(BookEditedEvent message)
|
||||||
_cache.Remove(message.Book.AuthorId.ToString());
|
_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)]
|
[EventHandleOrder(EventHandleOrder.First)]
|
||||||
public void Handle(BookFileDeletedEvent message)
|
public void Handle(BookFileDeletedEvent message)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
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;
|
||||||
|
using NzbDrone.Core.RootFolders;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Books
|
namespace NzbDrone.Core.Books
|
||||||
{
|
{
|
||||||
|
|
@ -30,6 +31,7 @@ public class RefreshBookService : RefreshEntityServiceBase<Book, Edition>,
|
||||||
{
|
{
|
||||||
private readonly IBookService _bookService;
|
private readonly IBookService _bookService;
|
||||||
private readonly IAuthorService _authorService;
|
private readonly IAuthorService _authorService;
|
||||||
|
private readonly IRootFolderService _rootFolderService;
|
||||||
private readonly IAddAuthorService _addAuthorService;
|
private readonly IAddAuthorService _addAuthorService;
|
||||||
private readonly IEditionService _editionService;
|
private readonly IEditionService _editionService;
|
||||||
private readonly IProvideAuthorInfo _authorInfo;
|
private readonly IProvideAuthorInfo _authorInfo;
|
||||||
|
|
@ -44,6 +46,7 @@ public class RefreshBookService : RefreshEntityServiceBase<Book, Edition>,
|
||||||
|
|
||||||
public RefreshBookService(IBookService bookService,
|
public RefreshBookService(IBookService bookService,
|
||||||
IAuthorService authorService,
|
IAuthorService authorService,
|
||||||
|
IRootFolderService rootFolderService,
|
||||||
IAddAuthorService addAuthorService,
|
IAddAuthorService addAuthorService,
|
||||||
IEditionService editionService,
|
IEditionService editionService,
|
||||||
IAuthorMetadataService authorMetadataService,
|
IAuthorMetadataService authorMetadataService,
|
||||||
|
|
@ -60,6 +63,7 @@ public RefreshBookService(IBookService bookService,
|
||||||
{
|
{
|
||||||
_bookService = bookService;
|
_bookService = bookService;
|
||||||
_authorService = authorService;
|
_authorService = authorService;
|
||||||
|
_rootFolderService = rootFolderService;
|
||||||
_addAuthorService = addAuthorService;
|
_addAuthorService = addAuthorService;
|
||||||
_editionService = editionService;
|
_editionService = editionService;
|
||||||
_authorInfo = authorInfo;
|
_authorInfo = authorInfo;
|
||||||
|
|
@ -142,7 +146,7 @@ protected override void EnsureNewParent(Book local, Book remote)
|
||||||
Metadata = remote.AuthorMetadata.Value,
|
Metadata = remote.AuthorMetadata.Value,
|
||||||
MetadataProfileId = oldAuthor.MetadataProfileId,
|
MetadataProfileId = oldAuthor.MetadataProfileId,
|
||||||
QualityProfileId = oldAuthor.QualityProfileId,
|
QualityProfileId = oldAuthor.QualityProfileId,
|
||||||
RootFolderPath = oldAuthor.RootFolderPath,
|
RootFolderPath = _rootFolderService.GetBestRootFolderPath(oldAuthor.Path),
|
||||||
Monitored = oldAuthor.Monitored,
|
Monitored = oldAuthor.Monitored,
|
||||||
Tags = oldAuthor.Tags
|
Tags = oldAuthor.Tags
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ public class AuthorController : RestControllerWithSignalR<AuthorResource, NzbDro
|
||||||
IHandle<BookImportedEvent>,
|
IHandle<BookImportedEvent>,
|
||||||
IHandle<BookEditedEvent>,
|
IHandle<BookEditedEvent>,
|
||||||
IHandle<BookFileDeletedEvent>,
|
IHandle<BookFileDeletedEvent>,
|
||||||
|
IHandle<AuthorAddedEvent>,
|
||||||
IHandle<AuthorUpdatedEvent>,
|
IHandle<AuthorUpdatedEvent>,
|
||||||
IHandle<AuthorEditedEvent>,
|
IHandle<AuthorEditedEvent>,
|
||||||
IHandle<AuthorDeletedEvent>,
|
IHandle<AuthorDeletedEvent>,
|
||||||
|
|
@ -255,6 +256,12 @@ public void Handle(BookFileDeletedEvent message)
|
||||||
BroadcastResourceChange(ModelAction.Updated, GetAuthorResource(message.BookFile.Author.Value));
|
BroadcastResourceChange(ModelAction.Updated, GetAuthorResource(message.BookFile.Author.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public void Handle(AuthorAddedEvent message)
|
||||||
|
{
|
||||||
|
BroadcastResourceChange(ModelAction.Updated, GetAuthorResource(message.Author));
|
||||||
|
}
|
||||||
|
|
||||||
[NonAction]
|
[NonAction]
|
||||||
public void Handle(AuthorUpdatedEvent message)
|
public void Handle(AuthorUpdatedEvent message)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue