From 95f30b23c81294b5fea9ff86fd40d335a76821e5 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 15 Apr 2023 23:39:57 +0300 Subject: [PATCH] Fixed: Exception thrown when marking download as complete (cherry picked from commit 9ebeee8b4fb04edfb709767b970f5e1d109bc4b9) --- .../Download/History/DownloadHistoryService.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core/Download/History/DownloadHistoryService.cs b/src/NzbDrone.Core/Download/History/DownloadHistoryService.cs index 6a8de39e2..a7a698f50 100644 --- a/src/NzbDrone.Core/Download/History/DownloadHistoryService.cs +++ b/src/NzbDrone.Core/Download/History/DownloadHistoryService.cs @@ -152,7 +152,7 @@ namespace NzbDrone.Core.Download.History var history = new DownloadHistory { EventType = DownloadHistoryEventType.FileImported, - ArtistId = message.TrackInfo.Artist.Id, + ArtistId = message.ImportedTrack.Artist.Value.Id, DownloadId = downloadId, SourceTitle = message.TrackInfo.Path, Date = DateTime.UtcNow, @@ -190,19 +190,21 @@ namespace NzbDrone.Core.Download.History public void Handle(DownloadCompletedEvent message) { + var downloadItem = message.TrackedDownload.DownloadItem; + var history = new DownloadHistory { EventType = DownloadHistoryEventType.DownloadImported, - ArtistId = message.TrackedDownload.RemoteAlbum.Artist.Id, - DownloadId = message.TrackedDownload.DownloadItem.DownloadId, - SourceTitle = message.TrackedDownload.DownloadItem.OutputPath.ToString(), + ArtistId = message.ArtistId, + DownloadId = downloadItem.DownloadId, + SourceTitle = downloadItem.Title, Date = DateTime.UtcNow, Protocol = message.TrackedDownload.Protocol, DownloadClientId = message.TrackedDownload.DownloadClient }; - history.Data.Add("DownloadClient", message.TrackedDownload.DownloadItem.DownloadClientInfo.Type); - history.Data.Add("DownloadClientName", message.TrackedDownload.DownloadItem.DownloadClientInfo.Name); + history.Data.Add("DownloadClient", downloadItem.DownloadClientInfo.Type); + history.Data.Add("DownloadClientName", downloadItem.DownloadClientInfo.Name); _repository.Insert(history); }