From bfcbb67054d0664bb334188ed309ef0bdea7984f Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 30 Jun 2024 20:47:00 +0300 Subject: [PATCH] Fixed: Already imported downloads appearing in Queue briefly (cherry picked from commit 8099ba10afded446779290de29b1baaf0be932c3) Closes #4877 --- src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs | 1 + src/NzbDrone.Core/Queue/QueueService.cs | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs b/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs index 174e0fb1b..ac62bbb37 100644 --- a/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs +++ b/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs @@ -46,6 +46,7 @@ namespace NzbDrone.Core.Test.QueueTests _trackedDownloads = Builder.CreateListOfSize(1) .All() + .With(v => v.IsTrackable = true) .With(v => v.DownloadItem = downloadItem) .With(v => v.RemoteAlbum = remoteAlbum) .Build() diff --git a/src/NzbDrone.Core/Queue/QueueService.cs b/src/NzbDrone.Core/Queue/QueueService.cs index 68c4389ba..e23bb47a8 100644 --- a/src/NzbDrone.Core/Queue/QueueService.cs +++ b/src/NzbDrone.Core/Queue/QueueService.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Queue public class QueueService : IQueueService, IHandle { private readonly IEventAggregator _eventAggregator; - private static List _queue = new List(); + private static List _queue = new (); private readonly IHistoryService _historyService; public QueueService(IEventAggregator eventAggregator, @@ -106,8 +106,11 @@ namespace NzbDrone.Core.Queue public void Handle(TrackedDownloadRefreshedEvent message) { - _queue = message.TrackedDownloads.OrderBy(c => c.DownloadItem.RemainingTime).SelectMany(MapQueue) - .ToList(); + _queue = message.TrackedDownloads + .Where(t => t.IsTrackable) + .OrderBy(c => c.DownloadItem.RemainingTime) + .SelectMany(MapQueue) + .ToList(); _eventAggregator.PublishEvent(new QueueUpdatedEvent()); }