mirror of
https://github.com/Readarr/Readarr
synced 2025-12-13 11:55:20 +01:00
Mark completed imports based on history as imported to remove from queue
This commit is contained in:
parent
0bb8672119
commit
975ff0baf3
1 changed files with 21 additions and 16 deletions
|
|
@ -159,27 +159,32 @@ public bool VerifyImport(TrackedDownload trackedDownload, List<ImportResult> imp
|
|||
|
||||
if (allEpisodesImportedInHistory)
|
||||
{
|
||||
// Log different error messages depending on the circumstances, but treat both as fully imported, because that's the reality.
|
||||
// The second message shouldn't be logged in most cases, but continued reporting would indicate an ongoing issue.
|
||||
if (atLeastOneEpisodeImported)
|
||||
{
|
||||
_logger.Debug("All books were imported in history for {0}", trackedDownload.DownloadItem.Title);
|
||||
trackedDownload.State = TrackedDownloadState.Imported;
|
||||
|
||||
var importedAuthorId = historyItems.Where(x => x.EventType == EntityHistoryEventType.BookFileImported)
|
||||
.Select(x => x.AuthorId)
|
||||
.MostCommon();
|
||||
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, trackedDownload.RemoteBook?.Author.Id ?? importedAuthorId));
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug()
|
||||
.Message("No books were just imported, but all books were previously imported, possible issue with download history.")
|
||||
.Property("AuthorId", trackedDownload.RemoteBook.Author.Id)
|
||||
.Property("DownloadId", trackedDownload.DownloadItem.DownloadId)
|
||||
.Property("Title", trackedDownload.DownloadItem.Title)
|
||||
.Property("Path", trackedDownload.DownloadItem.OutputPath.ToString())
|
||||
.WriteSentryWarn("DownloadHistoryIncomplete")
|
||||
.Write();
|
||||
}
|
||||
|
||||
_logger.Debug()
|
||||
.Message("No Episodes were just imported, but all episodes were previously imported, possible issue with download history.")
|
||||
.Property("AuthorId", trackedDownload.RemoteBook.Author.Id)
|
||||
.Property("DownloadId", trackedDownload.DownloadItem.DownloadId)
|
||||
.Property("Title", trackedDownload.DownloadItem.Title)
|
||||
.Property("Path", trackedDownload.DownloadItem.OutputPath.ToString())
|
||||
.WriteSentryWarn("DownloadHistoryIncomplete")
|
||||
.Write();
|
||||
trackedDownload.State = TrackedDownloadState.Imported;
|
||||
|
||||
var importedAuthorId = historyItems.Where(x => x.EventType == EntityHistoryEventType.BookFileImported)
|
||||
.Select(x => x.AuthorId)
|
||||
.MostCommon();
|
||||
_eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, trackedDownload.RemoteBook?.Author.Id ?? importedAuthorId));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
_logger.Debug("Not all books have been imported for {0}", trackedDownload.DownloadItem.Title);
|
||||
|
|
|
|||
Loading…
Reference in a new issue