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

View File

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

View File

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