mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-03 13:34:54 +00:00
Fixed: Ensure first history item when marked as failed is the selected item
(cherry picked from commit cf48bf304122bacc597de1d4d4429065d2358fa8) Closes #3557
This commit is contained in:
parent
cf33d433a4
commit
1775dc9fa8
1 changed files with 16 additions and 5 deletions
|
@ -40,12 +40,23 @@ public void MarkAsFailed(int historyId, bool skipRedownload = false)
|
|||
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 @@ public void MarkAsFailed(string downloadId, bool skipRedownload = false)
|
|||
{
|
||||
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 @@ private void PublishDownloadFailedEvent(List<EntityHistory> historyItems, string
|
|||
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…
Reference in a new issue