Changed: Force album refresh when artist refresh manually triggered (#374)

* Force album refresh when artist refresh manually triggered

* Refresh albums on single artist refresh
pull/379/head v0.3.0.430
Daniel Underwood 7 years ago committed by Qstick
parent d15d5ae6ba
commit d7d4f62737

@ -59,7 +59,7 @@ namespace NzbDrone.Core.Test.MusicTests
[Test] [Test]
public void should_log_error_if_musicbrainz_id_not_found() public void should_log_error_if_musicbrainz_id_not_found()
{ {
Subject.RefreshAlbumInfo(_albums); Subject.RefreshAlbumInfo(_albums, false);
Mocker.GetMock<IAlbumService>() Mocker.GetMock<IAlbumService>()
.Verify(v => v.UpdateMany(It.IsAny<List<Album>>()), Times.Never()); .Verify(v => v.UpdateMany(It.IsAny<List<Album>>()), Times.Never());
@ -75,7 +75,7 @@ namespace NzbDrone.Core.Test.MusicTests
GivenNewAlbumInfo(newAlbumInfo); GivenNewAlbumInfo(newAlbumInfo);
Subject.RefreshAlbumInfo(_albums); Subject.RefreshAlbumInfo(_albums, false);
Mocker.GetMock<IAlbumService>() Mocker.GetMock<IAlbumService>()
.Verify(v => v.UpdateMany(It.Is<List<Album>>(s => s.First().ForeignAlbumId == newAlbumInfo.ForeignAlbumId))); .Verify(v => v.UpdateMany(It.Is<List<Album>>(s => s.First().ForeignAlbumId == newAlbumInfo.ForeignAlbumId)));

@ -20,7 +20,7 @@ namespace NzbDrone.Core.Music
public interface IRefreshAlbumService public interface IRefreshAlbumService
{ {
void RefreshAlbumInfo(Album album); void RefreshAlbumInfo(Album album);
void RefreshAlbumInfo(List<Album> albums); void RefreshAlbumInfo(List<Album> albums, bool forceAlbumRefresh);
} }
public class RefreshAlbumService : IRefreshAlbumService, IExecute<RefreshAlbumCommand> public class RefreshAlbumService : IRefreshAlbumService, IExecute<RefreshAlbumCommand>
@ -50,11 +50,11 @@ namespace NzbDrone.Core.Music
_logger = logger; _logger = logger;
} }
public void RefreshAlbumInfo(List<Album> albums) public void RefreshAlbumInfo(List<Album> albums, bool forceAlbumRefresh)
{ {
foreach (var album in albums) foreach (var album in albums)
{ {
if (_checkIfAlbumShouldBeRefreshed.ShouldRefresh(album)) if (forceAlbumRefresh || _checkIfAlbumShouldBeRefreshed.ShouldRefresh(album))
{ {
RefreshAlbumInfo(album); RefreshAlbumInfo(album);
} }

@ -52,7 +52,7 @@ namespace NzbDrone.Core.Music
_logger = logger; _logger = logger;
} }
private void RefreshArtistInfo(Artist artist) private void RefreshArtistInfo(Artist artist, bool forceAlbumRefresh)
{ {
_logger.ProgressInfo("Updating Info for {0}", artist.Name); _logger.ProgressInfo("Updating Info for {0}", artist.Name);
@ -131,7 +131,7 @@ namespace NzbDrone.Core.Music
_addAlbumService.AddAlbums(newAlbumsList); _addAlbumService.AddAlbums(newAlbumsList);
_refreshAlbumService.RefreshAlbumInfo(updateAlbumsList); _refreshAlbumService.RefreshAlbumInfo(updateAlbumsList, forceAlbumRefresh);
_albumService.DeleteMany(existingAlbums); _albumService.DeleteMany(existingAlbums);
@ -160,7 +160,7 @@ namespace NzbDrone.Core.Music
if (message.ArtistId.HasValue) if (message.ArtistId.HasValue)
{ {
var artist = _artistService.GetArtist(message.ArtistId.Value); var artist = _artistService.GetArtist(message.ArtistId.Value);
RefreshArtistInfo(artist); RefreshArtistInfo(artist, true);
} }
else else
{ {
@ -168,11 +168,12 @@ namespace NzbDrone.Core.Music
foreach (var artist in allArtists) foreach (var artist in allArtists)
{ {
if (message.Trigger == CommandTrigger.Manual || _checkIfArtistShouldBeRefreshed.ShouldRefresh(artist)) var manualTrigger = message.Trigger == CommandTrigger.Manual;
if (manualTrigger || _checkIfArtistShouldBeRefreshed.ShouldRefresh(artist))
{ {
try try
{ {
RefreshArtistInfo(artist); RefreshArtistInfo(artist, manualTrigger);
} }
catch (Exception e) catch (Exception e)
{ {

Loading…
Cancel
Save