Fixed: Correctly add missing new artist when an album's artist changes in musicbrainz

Fixes LIDARR-H
This commit is contained in:
ta264 2022-08-03 21:05:28 +01:00
parent ded8602976
commit c1dd253bc1
3 changed files with 28 additions and 1 deletions

View File

@ -31,6 +31,7 @@ namespace Lidarr.Api.V1.Artist
IHandle<AlbumEditedEvent>, IHandle<AlbumEditedEvent>,
IHandle<AlbumDeletedEvent>, IHandle<AlbumDeletedEvent>,
IHandle<TrackFileDeletedEvent>, IHandle<TrackFileDeletedEvent>,
IHandle<ArtistAddedEvent>,
IHandle<ArtistUpdatedEvent>, IHandle<ArtistUpdatedEvent>,
IHandle<ArtistEditedEvent>, IHandle<ArtistEditedEvent>,
IHandle<ArtistsDeletedEvent>, IHandle<ArtistsDeletedEvent>,
@ -284,6 +285,12 @@ namespace Lidarr.Api.V1.Artist
BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.TrackFile.Artist.Value)); BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.TrackFile.Artist.Value));
} }
[NonAction]
public void Handle(ArtistAddedEvent message)
{
BroadcastResourceChange(ModelAction.Updated, GetArtistResource(message.Artist));
}
[NonAction] [NonAction]
public void Handle(ArtistUpdatedEvent message) public void Handle(ArtistUpdatedEvent message)
{ {

View File

@ -15,12 +15,14 @@ namespace NzbDrone.Core.ArtistStats
} }
public class ArtistStatisticsService : IArtistStatisticsService, public class ArtistStatisticsService : IArtistStatisticsService,
IHandle<ArtistAddedEvent>,
IHandle<ArtistUpdatedEvent>, IHandle<ArtistUpdatedEvent>,
IHandle<ArtistsDeletedEvent>, IHandle<ArtistsDeletedEvent>,
IHandle<AlbumAddedEvent>, IHandle<AlbumAddedEvent>,
IHandle<AlbumDeletedEvent>, IHandle<AlbumDeletedEvent>,
IHandle<AlbumImportedEvent>, IHandle<AlbumImportedEvent>,
IHandle<AlbumEditedEvent>, IHandle<AlbumEditedEvent>,
IHandle<AlbumUpdatedEvent>,
IHandle<TrackFileDeletedEvent> IHandle<TrackFileDeletedEvent>
{ {
private readonly IArtistStatisticsRepository _artistStatisticsRepository; private readonly IArtistStatisticsRepository _artistStatisticsRepository;
@ -68,6 +70,13 @@ namespace NzbDrone.Core.ArtistStats
return artistStatistics; return artistStatistics;
} }
[EventHandleOrder(EventHandleOrder.First)]
public void Handle(ArtistAddedEvent message)
{
_cache.Remove("AllArtists");
_cache.Remove(message.Artist.Id.ToString());
}
[EventHandleOrder(EventHandleOrder.First)] [EventHandleOrder(EventHandleOrder.First)]
public void Handle(ArtistUpdatedEvent message) public void Handle(ArtistUpdatedEvent message)
{ {
@ -114,6 +123,13 @@ namespace NzbDrone.Core.ArtistStats
_cache.Remove(message.Album.ArtistId.ToString()); _cache.Remove(message.Album.ArtistId.ToString());
} }
[EventHandleOrder(EventHandleOrder.First)]
public void Handle(AlbumUpdatedEvent message)
{
_cache.Remove("AllArtists");
_cache.Remove(message.Album.ArtistId.ToString());
}
[EventHandleOrder(EventHandleOrder.First)] [EventHandleOrder(EventHandleOrder.First)]
public void Handle(TrackFileDeletedEvent message) public void Handle(TrackFileDeletedEvent message)
{ {

View File

@ -14,6 +14,7 @@ using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource;
using NzbDrone.Core.Music.Commands; using NzbDrone.Core.Music.Commands;
using NzbDrone.Core.Music.Events; using NzbDrone.Core.Music.Events;
using NzbDrone.Core.RootFolders;
namespace NzbDrone.Core.Music namespace NzbDrone.Core.Music
{ {
@ -27,6 +28,7 @@ namespace NzbDrone.Core.Music
{ {
private readonly IAlbumService _albumService; private readonly IAlbumService _albumService;
private readonly IArtistService _artistService; private readonly IArtistService _artistService;
private readonly IRootFolderService _rootFolderService;
private readonly IAddArtistService _addArtistService; private readonly IAddArtistService _addArtistService;
private readonly IReleaseService _releaseService; private readonly IReleaseService _releaseService;
private readonly IProvideAlbumInfo _albumInfo; private readonly IProvideAlbumInfo _albumInfo;
@ -41,6 +43,7 @@ namespace NzbDrone.Core.Music
public RefreshAlbumService(IAlbumService albumService, public RefreshAlbumService(IAlbumService albumService,
IArtistService artistService, IArtistService artistService,
IRootFolderService rootFolderService,
IAddArtistService addArtistService, IAddArtistService addArtistService,
IArtistMetadataService artistMetadataService, IArtistMetadataService artistMetadataService,
IReleaseService releaseService, IReleaseService releaseService,
@ -57,6 +60,7 @@ namespace NzbDrone.Core.Music
{ {
_albumService = albumService; _albumService = albumService;
_artistService = artistService; _artistService = artistService;
_rootFolderService = rootFolderService;
_addArtistService = addArtistService; _addArtistService = addArtistService;
_releaseService = releaseService; _releaseService = releaseService;
_albumInfo = albumInfo; _albumInfo = albumInfo;
@ -123,7 +127,7 @@ namespace NzbDrone.Core.Music
Metadata = remote.ArtistMetadata.Value, Metadata = remote.ArtistMetadata.Value,
MetadataProfileId = oldArtist.MetadataProfileId, MetadataProfileId = oldArtist.MetadataProfileId,
QualityProfileId = oldArtist.QualityProfileId, QualityProfileId = oldArtist.QualityProfileId,
RootFolderPath = oldArtist.RootFolderPath, RootFolderPath = _rootFolderService.GetBestRootFolderPath(oldArtist.Path),
Monitored = oldArtist.Monitored, Monitored = oldArtist.Monitored,
Tags = oldArtist.Tags Tags = oldArtist.Tags
}; };