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/6/head
ta264 5 years ago
parent 8160f3d84a
commit 77d02a03a0

@ -111,7 +111,7 @@ namespace NzbDrone.Core.Test.MediaCoverTests
.Setup(v => v.FileExists(It.IsAny<string>())) .Setup(v => v.FileExists(It.IsAny<string>()))
.Returns(true); .Returns(true);
Subject.HandleAsync(new ArtistUpdatedEvent(_artist)); Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist));
Mocker.GetMock<IImageResizer>() Mocker.GetMock<IImageResizer>()
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(3)); .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>())) .Setup(v => v.FileExists(It.IsAny<string>()))
.Returns(false); .Returns(false);
Subject.HandleAsync(new ArtistUpdatedEvent(_artist)); Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist));
Mocker.GetMock<IImageResizer>() Mocker.GetMock<IImageResizer>()
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(3)); .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>())) .Setup(v => v.GetFileSize(It.IsAny<string>()))
.Returns(1000); .Returns(1000);
Subject.HandleAsync(new ArtistUpdatedEvent(_artist)); Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist));
Mocker.GetMock<IImageResizer>() Mocker.GetMock<IImageResizer>()
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Never()); .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>())) .Setup(v => v.GetFileSize(It.IsAny<string>()))
.Returns(0); .Returns(0);
Subject.HandleAsync(new ArtistUpdatedEvent(_artist)); Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist));
Mocker.GetMock<IImageResizer>() Mocker.GetMock<IImageResizer>()
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(3)); .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>())) .Setup(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()))
.Throws<ApplicationException>(); .Throws<ApplicationException>();
Subject.HandleAsync(new ArtistUpdatedEvent(_artist)); Subject.HandleAsync(new ArtistRefreshCompleteEvent(_artist));
Mocker.GetMock<IImageResizer>() Mocker.GetMock<IImageResizer>()
.Verify(v => v.Resize(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Exactly(3)); .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 : public class MediaCoverService :
IHandleAsync<ArtistUpdatedEvent>, IHandleAsync<ArtistRefreshCompleteEvent>,
IHandleAsync<ArtistDeletedEvent>, IHandleAsync<ArtistDeletedEvent>,
IMapCoversToLocal IMapCoversToLocal
{ {
@ -287,7 +287,7 @@ namespace NzbDrone.Core.MediaCover
} }
} }
public void HandleAsync(ArtistUpdatedEvent message) public void HandleAsync(ArtistRefreshCompleteEvent message)
{ {
EnsureArtistCovers(message.Artist); 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)); _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) protected override void PublishChildrenUpdatedEvent(Artist entity, List<Album> newChildren, List<Album> updateChildren)
{ {
_eventAggregator.PublishEvent(new AlbumInfoRefreshedEvent(entity, newChildren, updateChildren)); _eventAggregator.PublishEvent(new AlbumInfoRefreshedEvent(entity, newChildren, updateChildren));
@ -297,7 +302,6 @@ namespace NzbDrone.Core.Music
{ {
var trigger = message.Trigger; var trigger = message.Trigger;
var isNew = message.IsNewArtist; var isNew = message.IsNewArtist;
_eventAggregator.PublishEvent(new ArtistRefreshStartingEvent(trigger == CommandTrigger.Manual));
if (message.ArtistId.HasValue) if (message.ArtistId.HasValue)
{ {

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

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

Loading…
Cancel
Save