mirror of
https://github.com/Readarr/Readarr.git
synced 2026-01-29 16:21:18 -05:00
Fixed: Avoid NullRef from ArtistStats when linking albumStats
This commit is contained in:
@@ -73,10 +73,7 @@ protected AlbumResource MapToResource(Album album, bool includeArtist)
|
||||
{
|
||||
var artist = album.Artist ?? _artistService.GetArtist(album.ArtistId);
|
||||
|
||||
if (includeArtist)
|
||||
{
|
||||
resource.Artist = artist.ToResource();
|
||||
}
|
||||
resource.Artist = artist.ToResource();
|
||||
}
|
||||
|
||||
FetchAndLinkAlbumStatistics(resource);
|
||||
@@ -99,14 +96,10 @@ protected List<AlbumResource> MapToResource(List<Album> albums, bool includeArti
|
||||
var artist = album.Artist ?? artistDict.GetValueOrDefault(albums[i].ArtistId) ?? _artistService.GetArtist(albums[i].ArtistId);
|
||||
artistDict[artist.Id] = artist;
|
||||
|
||||
if (includeArtist)
|
||||
{
|
||||
resource.Artist = artist.ToResource();
|
||||
}
|
||||
resource.Artist = artist.ToResource();
|
||||
}
|
||||
}
|
||||
|
||||
var artistList = albums.DistinctBy(a => a.ArtistId).ToList();
|
||||
|
||||
var artistStats = _artistStatisticsService.ArtistStatistics();
|
||||
LinkArtistStatistics(result, artistStats);
|
||||
|
||||
@@ -129,7 +122,7 @@ private void LinkArtistStatistics(List<AlbumResource> resources, List<ArtistStat
|
||||
|
||||
private void LinkArtistStatistics(AlbumResource resource, ArtistStatistics artistStatistics)
|
||||
{
|
||||
if (artistStatistics.AlbumStatistics != null)
|
||||
if (artistStatistics?.AlbumStatistics != null)
|
||||
{
|
||||
var dictAlbumStats = artistStatistics.AlbumStatistics.ToDictionary(v => v.AlbumId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user