Fixed: Previously imported downloads reappear in queue

Fixes #3496
This commit is contained in:
Mark McDowall 2020-01-07 16:55:13 -08:00
parent 29117fc222
commit fa4060b7fe
1 changed files with 18 additions and 10 deletions

View File

@ -110,19 +110,27 @@ namespace NzbDrone.Core.Download.TrackedDownloads
var firstHistoryItem = historyItems.First();
var state = GetStateFromHistory(firstHistoryItem.EventType);
trackedDownload.State = state;
// TODO: Restore check to confirm all files were imported
// This will treat partially imported downloads as imported (as it was before), which means a partially imported download after a
// restart will get marked as imported without importing the restart of the files.
// One potential issue here is if the latest is imported, but other episodes are ignored or never imported.
// It's unlikely that will happen, but could happen if additional episodes are added to season after it's already imported.
if (state == TrackedDownloadState.Imported)
{
var allImported = _trackedDownloadAlreadyImported.IsImported(trackedDownload, historyItems);
trackedDownload.State = allImported ? TrackedDownloadState.Imported : TrackedDownloadState.Downloading;
}
else
{
trackedDownload.State = state;
}
// if (state == TrackedDownloadState.Imported)
// {
// trackedDownload.State = TrackedDownloadState.Imported;
//
// var allImported = _trackedDownloadAlreadyImported.IsImported(trackedDownload, historyItems);
//
// trackedDownload.State = allImported ? TrackedDownloadState.Imported : TrackedDownloadState.Downloading;
// }
// else
// {
// trackedDownload.State = state;
// }
var grabbedEvent = historyItems.FirstOrDefault(v => v.EventType == HistoryEventType.Grabbed);
trackedDownload.Indexer = grabbedEvent?.Data["indexer"];