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

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.History;
@ -12,10 +13,20 @@ namespace NzbDrone.Core.Download.TrackedDownloads
public class TrackedDownloadAlreadyImported : ITrackedDownloadAlreadyImported
{
private readonly Logger _logger;
public TrackedDownloadAlreadyImported(Logger logger)
{
_logger = logger;
}
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())
{
_logger.Trace("No history for {0}", trackedDownload.DownloadItem.Title);
return false;
}
@ -25,12 +36,17 @@ namespace NzbDrone.Core.Download.TrackedDownloads
if (lastHistoryItem == null)
{
_logger.Trace("No history for episode: S{0:00}E{1:00} [{2}]", e.SeasonNumber, e.EpisodeNumber, e.Id);
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;
});
_logger.Trace("All episodes for '{0}' have been imported: {1}", trackedDownload.DownloadItem.Title, 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)
{
_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)
{
_logger.Trace("Episode file has not been imported");
continue;
}
// If the release was grabbed again after importing don't reject it
if (lastGrabbed != null && lastGrabbed.Date.After(lastImported.Date))
{
_logger.Trace("Episode file was grabbed again after importing");
continue;
}