Fixed: Ensure first history item when marked as failed is the selected item

(cherry picked from commit cf48bf304122bacc597de1d4d4429065d2358fa8)

Closes #3557
pull/4547/head v2.1.6.3993
Mark McDowall 2 years ago committed by Bogdan
parent cf33d433a4
commit 1775dc9fa8

@ -40,12 +40,23 @@ namespace NzbDrone.Core.Download
if (downloadId.IsNullOrWhiteSpace())
{
PublishDownloadFailedEvent(new List<EntityHistory> { history }, "Manually marked as failed", skipRedownload: skipRedownload);
return;
}
else
var grabbedHistory = new List<EntityHistory>();
// If the history item is a grabbed item (it should be, at least from the UI) add it as the first history item
if (history.EventType == EntityHistoryEventType.Grabbed)
{
var grabbedHistory = _historyService.Find(downloadId, EntityHistoryEventType.Grabbed).ToList();
PublishDownloadFailedEvent(grabbedHistory, "Manually marked as failed");
grabbedHistory.Add(history);
}
// Add any other history items for the download ID then filter out any duplicate history items.
grabbedHistory.AddRange(_historyService.Find(downloadId, EntityHistoryEventType.Grabbed));
grabbedHistory = grabbedHistory.DistinctBy(h => h.Id).ToList();
PublishDownloadFailedEvent(grabbedHistory, "Manually marked as failed");
}
public void MarkAsFailed(string downloadId, bool skipRedownload = false)
@ -56,7 +67,7 @@ namespace NzbDrone.Core.Download
{
var trackedDownload = _trackedDownloadService.Find(downloadId);
PublishDownloadFailedEvent(history, "Manually marked as failed", trackedDownload, skipRedownload);
PublishDownloadFailedEvent(history, "Manually marked as failed", trackedDownload, skipRedownload: skipRedownload);
}
}
@ -124,7 +135,7 @@ namespace NzbDrone.Core.Download
var downloadFailedEvent = new DownloadFailedEvent
{
ArtistId = historyItem.ArtistId,
AlbumIds = historyItems.Select(h => h.AlbumId).ToList(),
AlbumIds = historyItems.Select(h => h.AlbumId).Distinct().ToList(),
Quality = historyItem.Quality,
SourceTitle = historyItem.SourceTitle,
DownloadClient = historyItem.Data.GetValueOrDefault(EntityHistory.DOWNLOAD_CLIENT),

Loading…
Cancel
Save