Add artist refresh completed event

Always fires unlike update, which only fires on actual update.  Use
this to make sure media covers are up to date on refresh
pull/865/head
ta264 6 years ago
parent 8160f3d84a
commit 77d02a03a0

@ -111,7 +111,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
.Setup(v => v.FileExists(It.IsAny<string>()))
.Returns(true);
Subject.HandleAsync(new ArtistUpdatedEvent(_artist));
Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist));
Mocker.GetMock<IImageResizer>()
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(3));
@ -132,7 +132,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
.Setup(v => v.FileExists(It.IsAny<string>()))
.Returns(false);
Subject.HandleAsync(new ArtistUpdatedEvent(_artist));
Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist));
Mocker.GetMock<IImageResizer>()
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(3));
@ -157,7 +157,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
.Setup(v => v.GetFileSize(It.IsAny<string>()))
.Returns(1000);
Subject.HandleAsync(new ArtistUpdatedEvent(_artist));
Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist));
Mocker.GetMock<IImageResizer>()
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Never());
@ -182,7 +182,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
.Setup(v => v.GetFileSize(It.IsAny<string>()))
.Returns(0);
Subject.HandleAsync(new ArtistUpdatedEvent(_artist));
Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist));
Mocker.GetMock<IImageResizer>()
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(3));
@ -207,7 +207,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
.Setup(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()))
.Throws<ApplicationException>();
Subject.HandleAsync(new ArtistUpdatedEvent(_artist));
Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist));
Mocker.GetMock<IImageResizer>()
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(3));

@ -22,7 +22,7 @@ namespace NzbDrone.Core.MediaCover
}
public class MediaCoverService :
IHandleAsync<ArtistUpdatedEvent>,
IHandleAsync<ArtistRefreshCompleteEvent>,
IHandleAsync<ArtistDeletedEvent>,
IMapCoversToLocal
{
@ -287,7 +287,7 @@ namespace NzbDrone.Core.MediaCover
}
}
public void HandleAsync(ArtistUpdatedEvent message)
public void HandleAsync(ArtistRefreshCompleteEvent message)
{
EnsureArtistCovers(message.Artist);

@ -0,0 +1,14 @@
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Music.Events
{
public class ArtistRefreshCompleteEvent : IEvent
{
public Artist Artist { get; set; }
public ArtistRefreshCompleteEvent(Artist artist)
{
Artist = artist;
}
}
}

@ -1,18 +0,0 @@
using NzbDrone.Common.Messaging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Music.Events
{
public class ArtistRefreshStartingEvent : IEvent
{
public bool ManualTrigger { get; set; }
public ArtistRefreshStartingEvent(bool manualTrigger)
{
ManualTrigger = manualTrigger;
}
}
}

@ -247,6 +247,11 @@ namespace NzbDrone.Core.Music
_eventAggregator.PublishEvent(new ArtistUpdatedEvent(entity));
}
protected virtual void PublishRefreshCompleteEvent(Artist entity)
{
_eventAggregator.PublishEvent(new ArtistRefreshCompleteEvent(entity));
}
protected override void PublishChildrenUpdatedEvent(Artist entity, List<Album> newChildren, List<Album> updateChildren)
{
_eventAggregator.PublishEvent(new AlbumInfoRefreshedEvent(entity, newChildren, updateChildren));
@ -297,7 +302,6 @@ namespace NzbDrone.Core.Music
{
var trigger = message.Trigger;
var isNew = message.IsNewArtist;
_eventAggregator.PublishEvent(new ArtistRefreshStartingEvent(trigger == CommandTrigger.Manual));
if (message.ArtistId.HasValue)
{

@ -100,7 +100,11 @@ namespace NzbDrone.Core.Music
protected virtual void PublishEntityUpdatedEvent(Entity entity)
{
}
protected virtual void PublishRefreshCompleteEvent(Entity entity)
{
}
protected virtual void PublishChildrenUpdatedEvent(Entity entity, List<Child> newChildren, List<Child> updateChildren)
{
}
@ -185,6 +189,8 @@ namespace NzbDrone.Core.Music
PublishEntityUpdatedEvent(local);
}
PublishRefreshCompleteEvent(local);
_logger.Debug($"Finished {typeof(Entity).Name} refresh for {local}");
return updated;

@ -893,7 +893,7 @@
<Compile Include="Music\Events\ArtistDeletedEvent.cs" />
<Compile Include="Music\Events\AlbumEditedEvent.cs" />
<Compile Include="Music\Events\ArtistEditedEvent.cs" />
<Compile Include="Music\Events\ArtistRefreshStartingEvent.cs" />
<Compile Include="Music\Events\ArtistRefreshCompleteEvent.cs" />
<Compile Include="Music\Events\ArtistUpdatedEvent.cs" />
<Compile Include="Music\Events\AlbumInfoRefreshedEvent.cs" />
<Compile Include="Music\Ratings.cs" />

Loading…
Cancel
Save