From 7bdb3e437d61aac5ad6274bb3f02d431ebb40cbc Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 25 Jun 2024 15:51:20 -0700 Subject: [PATCH] New: Improve UI status when downloads cannot be imported automatically (cherry picked from commit 6d5ff9c4d6993d16848980aea499a45b1b51d95c) Closes #10107 --- frontend/src/Activity/Queue/QueueStatus.js | 5 +++++ .../ImportFixture.cs | 2 +- .../Download/CompletedDownloadService.cs | 16 +++++++++------- .../Download/TrackedDownloads/TrackedDownload.cs | 1 + src/NzbDrone.Core/Localization/Core/en.json | 1 + 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/frontend/src/Activity/Queue/QueueStatus.js b/frontend/src/Activity/Queue/QueueStatus.js index c6e8cf5dd..f7cab31ca 100644 --- a/frontend/src/Activity/Queue/QueueStatus.js +++ b/frontend/src/Activity/Queue/QueueStatus.js @@ -70,6 +70,11 @@ function QueueStatus(props) { iconName = icons.DOWNLOADED; title = translate('Downloaded'); + if (trackedDownloadState === 'importBlocked') { + title += ` - ${translate('UnableToImportAutomatically')}`; + iconKind = kinds.WARNING; + } + if (trackedDownloadState === 'importPending') { title += ` - ${translate('WaitingToImport')}`; iconKind = kinds.PURPLE; diff --git a/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ImportFixture.cs b/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ImportFixture.cs index 4c54083c4..cd098da27 100644 --- a/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ImportFixture.cs +++ b/src/NzbDrone.Core.Test/Download/CompletedDownloadServiceTests/ImportFixture.cs @@ -207,7 +207,7 @@ private void AssertNotImported() Mocker.GetMock() .Verify(v => v.PublishEvent(It.IsAny()), Times.Never()); - _trackedDownload.State.Should().Be(TrackedDownloadState.ImportPending); + _trackedDownload.State.Should().Be(TrackedDownloadState.ImportBlocked); } private void AssertImported() diff --git a/src/NzbDrone.Core/Download/CompletedDownloadService.cs b/src/NzbDrone.Core/Download/CompletedDownloadService.cs index 3be210728..20a8ea397 100644 --- a/src/NzbDrone.Core/Download/CompletedDownloadService.cs +++ b/src/NzbDrone.Core/Download/CompletedDownloadService.cs @@ -63,8 +63,8 @@ public void Check(TrackedDownload trackedDownload) SetImportItem(trackedDownload); - // Only process tracked downloads that are still downloading - if (trackedDownload.State != TrackedDownloadState.Downloading) + // Only process tracked downloads that are still downloading or have been blocked for importing due to an issue with matching + if (trackedDownload.State != TrackedDownloadState.Downloading && trackedDownload.State != TrackedDownloadState.ImportBlocked) { return; } @@ -95,7 +95,7 @@ public void Check(TrackedDownload trackedDownload) if (movie == null) { trackedDownload.Warn("Movie title mismatch, automatic import is not possible. Manual Import required."); - SendManualInteractionRequiredNotification(trackedDownload); + SetStateToImportBlocked(trackedDownload); return; } @@ -107,7 +107,7 @@ public void Check(TrackedDownload trackedDownload) if (movieMatchType == MovieMatchType.Id && releaseSource != ReleaseSourceType.InteractiveSearch) { trackedDownload.Warn("Found matching movie via grab history, but release was matched to movie by ID. Manual Import required."); - SendManualInteractionRequiredNotification(trackedDownload); + SetStateToImportBlocked(trackedDownload); return; } @@ -128,7 +128,7 @@ public void Import(TrackedDownload trackedDownload) if (trackedDownload.RemoteMovie?.Movie == null) { trackedDownload.Warn("Unable to parse download, automatic import is not possible."); - SendManualInteractionRequiredNotification(trackedDownload); + SetStateToImportBlocked(trackedDownload); return; } @@ -186,7 +186,7 @@ public void Import(TrackedDownload trackedDownload) if (statusMessages.Any()) { trackedDownload.Warn(statusMessages.ToArray()); - SendManualInteractionRequiredNotification(trackedDownload); + SetStateToImportBlocked(trackedDownload); } } @@ -245,8 +245,10 @@ public bool VerifyImport(TrackedDownload trackedDownload, List imp return false; } - private void SendManualInteractionRequiredNotification(TrackedDownload trackedDownload) + private void SetStateToImportBlocked(TrackedDownload trackedDownload) { + trackedDownload.State = TrackedDownloadState.ImportBlocked; + if (!trackedDownload.HasNotifiedManualInteractionRequired) { var grabbedHistories = _historyService.FindByDownloadId(trackedDownload.DownloadItem.DownloadId).Where(h => h.EventType == MovieHistoryEventType.Grabbed).ToList(); diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs index 977461bf7..77f628b7a 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownload.cs @@ -40,6 +40,7 @@ public void Warn(params TrackedDownloadStatusMessage[] statusMessages) public enum TrackedDownloadState { Downloading, + ImportBlocked, ImportPending, Importing, Imported, diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index fdbeb8a3f..05def6f6f 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -1705,6 +1705,7 @@ "UiSettingsLoadError": "Unable to load UI settings", "UiSettingsSummary": "Calendar, date and color impaired options", "Umask": "Umask", + "UnableToImportAutomatically": "Unable to Import Automatically", "UnableToLoadAltTitle": "Unable to load alternative titles.", "UnableToLoadCollections": "Unable to load collections", "UnableToLoadManualImportItems": "Unable to load manual import items",