Fixed: Manual import for unknown series items will properly mark as imported

This commit is contained in:
Mark McDowall 2020-05-24 10:11:10 -07:00
parent 4988655568
commit d3bd90e4b9
5 changed files with 15 additions and 6 deletions

View File

@ -141,7 +141,7 @@ namespace NzbDrone.Core.Download
if (allEpisodesImported) if (allEpisodesImported)
{ {
trackedDownload.State = TrackedDownloadState.Imported; trackedDownload.State = TrackedDownloadState.Imported;
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, trackedDownload.RemoteEpisode.Series.Id));
return true; return true;
} }
@ -165,7 +165,7 @@ namespace NzbDrone.Core.Download
if (allEpisodesImportedInHistory) if (allEpisodesImportedInHistory)
{ {
trackedDownload.State = TrackedDownloadState.Imported; trackedDownload.State = TrackedDownloadState.Imported;
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, trackedDownload.RemoteEpisode.Series.Id));
return true; return true;
} }
} }

View File

@ -6,10 +6,12 @@ namespace NzbDrone.Core.Download
public class DownloadCompletedEvent : IEvent public class DownloadCompletedEvent : IEvent
{ {
public TrackedDownload TrackedDownload { get; private set; } public TrackedDownload TrackedDownload { get; private set; }
public int SeriesId { get; set; }
public DownloadCompletedEvent(TrackedDownload trackedDownload) public DownloadCompletedEvent(TrackedDownload trackedDownload, int seriesId)
{ {
TrackedDownload = trackedDownload; TrackedDownload = trackedDownload;
SeriesId = seriesId;
} }
} }
} }

View File

@ -41,7 +41,8 @@ namespace NzbDrone.Core.Download
foreach (var trackedDownload in trackedDownloads) foreach (var trackedDownload in trackedDownloads)
{ {
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload,
trackedDownload.RemoteEpisode.Series.Id));
} }
} }

View File

@ -88,6 +88,12 @@ namespace NzbDrone.Core.Download.History
public void Handle(EpisodeGrabbedEvent message) public void Handle(EpisodeGrabbedEvent message)
{ {
// Don't store grabbed events for clients that don't download IDs
if (message.DownloadId.IsNullOrWhiteSpace())
{
return;
}
var history = new DownloadHistory var history = new DownloadHistory
{ {
EventType = DownloadHistoryEventType.DownloadGrabbed, EventType = DownloadHistoryEventType.DownloadGrabbed,
@ -155,7 +161,7 @@ namespace NzbDrone.Core.Download.History
var history = new DownloadHistory var history = new DownloadHistory
{ {
EventType = DownloadHistoryEventType.DownloadImported, EventType = DownloadHistoryEventType.DownloadImported,
SeriesId = message.TrackedDownload.RemoteEpisode.Series.Id, SeriesId = message.SeriesId,
DownloadId = message.TrackedDownload.DownloadItem.DownloadId, DownloadId = message.TrackedDownload.DownloadItem.DownloadId,
SourceTitle = message.TrackedDownload.DownloadItem.OutputPath.ToString(), SourceTitle = message.TrackedDownload.DownloadItem.OutputPath.ToString(),
Date = DateTime.UtcNow, Date = DateTime.UtcNow,

View File

@ -372,7 +372,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual
if (allEpisodesImported) if (allEpisodesImported)
{ {
trackedDownload.State = TrackedDownloadState.Imported; trackedDownload.State = TrackedDownloadState.Imported;
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, imported.First().ImportDecision.LocalEpisode.Series.Id));
} }
} }
} }