1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-26 01:27:00 +00:00

Fixed: NullReferenceException manually importing an unparseable release

Fixes Sentry LIDARR-GY

(cherry picked from commit 702480852e742c39edacbe40977837381dc884ba)
This commit is contained in:
ta264 2021-08-04 21:58:33 +01:00
parent 334044ae31
commit f7925ff5d6

View file

@ -384,7 +384,17 @@ public void Execute(ManualImportCommand message)
} }
} }
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; trackedDownload.State = TrackedDownloadState.Imported;
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, importArtist.Id)); _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, importArtist.Id));