Additional logging when trying to complete tracked downloads

This commit is contained in:
Mark McDowall 2020-05-30 16:40:41 -07:00
parent 069fc5cd33
commit 14c9b6aaf4
4 changed files with 26 additions and 2 deletions

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using NLog;
using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.Download.TrackedDownloads; using NzbDrone.Core.Download.TrackedDownloads;
@ -29,13 +30,15 @@ namespace NzbDrone.Core.Download
private readonly IParsingService _parsingService; private readonly IParsingService _parsingService;
private readonly ISeriesService _seriesService; private readonly ISeriesService _seriesService;
private readonly ITrackedDownloadAlreadyImported _trackedDownloadAlreadyImported; private readonly ITrackedDownloadAlreadyImported _trackedDownloadAlreadyImported;
private readonly Logger _logger;
public CompletedDownloadService(IEventAggregator eventAggregator, public CompletedDownloadService(IEventAggregator eventAggregator,
IHistoryService historyService, IHistoryService historyService,
IDownloadedEpisodesImportService downloadedEpisodesImportService, IDownloadedEpisodesImportService downloadedEpisodesImportService,
IParsingService parsingService, IParsingService parsingService,
ISeriesService seriesService, ISeriesService seriesService,
ITrackedDownloadAlreadyImported trackedDownloadAlreadyImported) ITrackedDownloadAlreadyImported trackedDownloadAlreadyImported,
Logger logger)
{ {
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
_historyService = historyService; _historyService = historyService;
@ -140,6 +143,7 @@ namespace NzbDrone.Core.Download
if (allEpisodesImported) if (allEpisodesImported)
{ {
_logger.Debug("All episodes were imported for {0}", trackedDownload.DownloadItem.Title);
trackedDownload.State = TrackedDownloadState.Imported; trackedDownload.State = TrackedDownloadState.Imported;
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, trackedDownload.RemoteEpisode.Series.Id)); _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, trackedDownload.RemoteEpisode.Series.Id));
return true; return true;
@ -164,12 +168,14 @@ namespace NzbDrone.Core.Download
if (allEpisodesImportedInHistory) if (allEpisodesImportedInHistory)
{ {
_logger.Debug("All episodes were imported in history for {0}", trackedDownload.DownloadItem.Title);
trackedDownload.State = TrackedDownloadState.Imported; trackedDownload.State = TrackedDownloadState.Imported;
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, trackedDownload.RemoteEpisode.Series.Id)); _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, trackedDownload.RemoteEpisode.Series.Id));
return true; return true;
} }
} }
_logger.Debug("Not all episodes have been imported for {0}", trackedDownload.DownloadItem.Title);
return false; return false;
} }
} }

View File

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NLog;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Core.History; using NzbDrone.Core.History;
@ -12,10 +13,20 @@ namespace NzbDrone.Core.Download.TrackedDownloads
public class TrackedDownloadAlreadyImported : ITrackedDownloadAlreadyImported public class TrackedDownloadAlreadyImported : ITrackedDownloadAlreadyImported
{ {
private readonly Logger _logger;
public TrackedDownloadAlreadyImported(Logger logger)
{
_logger = logger;
}
public bool IsImported(TrackedDownload trackedDownload, List<EpisodeHistory> historyItems) public bool IsImported(TrackedDownload trackedDownload, List<EpisodeHistory> historyItems)
{ {
_logger.Trace("Checking if all episodes for '{0}' have been imported", trackedDownload.DownloadItem.Title);
if (historyItems.Empty()) if (historyItems.Empty())
{ {
_logger.Trace("No history for {0}", trackedDownload.DownloadItem.Title);
return false; return false;
} }
@ -25,12 +36,17 @@ namespace NzbDrone.Core.Download.TrackedDownloads
if (lastHistoryItem == null) if (lastHistoryItem == null)
{ {
_logger.Trace("No history for episode: S{0:00}E{1:00} [{2}]", e.SeasonNumber, e.EpisodeNumber, e.Id);
return false; return false;
} }
_logger.Trace("Last event for episode: S{0:00}E{1:00} [{2}] is: {3}", e.SeasonNumber, e.EpisodeNumber, e.Id, lastHistoryItem.EventType);
return lastHistoryItem.EventType == EpisodeHistoryEventType.DownloadFolderImported; return lastHistoryItem.EventType == EpisodeHistoryEventType.DownloadFolderImported;
}); });
_logger.Trace("All episodes for '{0}' have been imported: {1}", trackedDownload.DownloadItem.Title, allEpisodesImportedInHistory);
return allEpisodesImportedInHistory; return allEpisodesImportedInHistory;
} }
} }

View File

@ -137,7 +137,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
} }
} }
// Track it so it can be displayed in the queue even though we can't determine which serires it is for // Track it so it can be displayed in the queue even though we can't determine which series it is for
if (trackedDownload.RemoteEpisode == null) if (trackedDownload.RemoteEpisode == null)
{ {
_logger.Trace("No Episode found for download '{0}'", trackedDownload.DownloadItem.Title); _logger.Trace("No Episode found for download '{0}'", trackedDownload.DownloadItem.Title);

View File

@ -44,12 +44,14 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
if (lastImported == null) if (lastImported == null)
{ {
_logger.Trace("Episode file has not been imported");
continue; continue;
} }
// If the release was grabbed again after importing don't reject it // If the release was grabbed again after importing don't reject it
if (lastGrabbed != null && lastGrabbed.Date.After(lastImported.Date)) if (lastGrabbed != null && lastGrabbed.Date.After(lastImported.Date))
{ {
_logger.Trace("Episode file was grabbed again after importing");
continue; continue;
} }