Fixed: NullReferenceException manually importing an unparseable release

Fixes Sentry LIDARR-GY

(cherry picked from commit 702480852e742c39edacbe40977837381dc884ba)
pull/2347/head
ta264 3 years ago
parent 334044ae31
commit f7925ff5d6

@ -384,7 +384,17 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Manual
}
}
if (groupedTrackedDownload.Select(c => c.ImportResult).Count(c => c.Result == ImportResultType.Imported) >= Math.Max(1, trackedDownload.RemoteAlbum.Albums.Count))
var remoteTrackCount = Math.Max(1,
trackedDownload.RemoteAlbum?.Albums.Sum(x =>
x.AlbumReleases.Value.Where(y => y.Monitored).Sum(z => z.TrackCount)) ?? 1);
var importResults = groupedTrackedDownload.Select(x => x.ImportResult).ToList();
var importedTrackCount = importResults.Where(c => c.Result == ImportResultType.Imported)
.SelectMany(c => c.ImportDecision.Item.Tracks)
.Count();
var allTracksImported = importResults.All(c => c.Result == ImportResultType.Imported) || importedTrackCount >= remoteTrackCount;
if (allTracksImported)
{
trackedDownload.State = TrackedDownloadState.Imported;
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, importArtist.Id));

Loading…
Cancel
Save