Fixed: Null reference error when import list adds new album to existing artist

(cherry picked from commit 5e3045db86748d0ab407a6785007cb6bbd4f46a6)
pull/2877/head
Thomas White 2 years ago committed by ta264
parent d96775a4a3
commit 33bb5960e5

@ -89,14 +89,14 @@ namespace NzbDrone.Core.Test.ImportListTests
{
Mocker.GetMock<IArtistService>()
.Setup(v => v.FindById(_importListReports.First().ArtistMusicBrainzId))
.Returns(new Artist { ForeignArtistId = _importListReports.First().ArtistMusicBrainzId });
.Returns(new Artist { Id = 1, ForeignArtistId = _importListReports.First().ArtistMusicBrainzId });
}
private void WithExistingAlbum()
{
Mocker.GetMock<IAlbumService>()
.Setup(v => v.FindById(_importListReports.First().AlbumMusicBrainzId))
.Returns(new Album { ForeignAlbumId = _importListReports.First().AlbumMusicBrainzId });
.Returns(new Album { Id = 1, ForeignAlbumId = _importListReports.First().AlbumMusicBrainzId });
}
private void WithExcludedArtist()
@ -215,6 +215,7 @@ namespace NzbDrone.Core.Test.ImportListTests
public void should_add_if_existing_artist_but_new_album()
{
WithAlbumId();
WithArtistId();
WithExistingArtist();
Subject.Execute(new ImportListSyncCommand());

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using NLog;
using NzbDrone.Common.Extensions;
@ -243,8 +244,9 @@ namespace NzbDrone.Core.ImportLists
}
};
if (importList.ShouldMonitor == ImportListMonitorType.SpecificAlbum)
if (importList.ShouldMonitor == ImportListMonitorType.SpecificAlbum && toAddArtist.AddOptions != null)
{
Debug.Assert(toAddArtist.Id == 0, "new artist added but ID is not 0");
toAddArtist.AddOptions.AlbumsToMonitor.Add(toAdd.ForeignAlbumId);
}

Loading…
Cancel
Save