mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-26 07:42:49 +00:00
Fixed: Avoid NullRef from ArtistStats when linking albumStats
This commit is contained in:
parent
029e057c06
commit
de224bcce5
1 changed files with 4 additions and 11 deletions
|
@ -73,11 +73,8 @@ protected AlbumResource MapToResource(Album album, bool includeArtist)
|
|||
{
|
||||
var artist = album.Artist ?? _artistService.GetArtist(album.ArtistId);
|
||||
|
||||
if (includeArtist)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue