mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-25 09:12:17 +00:00
Fixed: NullReferenceException manually importing an unparseable release
Fixes Sentry LIDARR-GY (cherry picked from commit 702480852e742c39edacbe40977837381dc884ba)
This commit is contained in:
parent
334044ae31
commit
f7925ff5d6
1 changed files with 11 additions and 1 deletions
|
@ -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));
|
||||||
|
|
Loading…
Reference in a new issue