From b5e6a3687868563b4a2d624db5541aa3925d6997 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) --- 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 3b2892178..6a2f706db 100644 --- a/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs +++ b/src/NzbDrone.Core.Test/QueueTests/QueueServiceFixture.cs @@ -38,6 +38,7 @@ public void SetUp() _trackedDownloads = Builder.CreateListOfSize(1) .All() + .With(v => v.IsTrackable = true) .With(v => v.DownloadItem = downloadItem) .With(v => v.RemoteMovie = remoteEpisode) .Build() diff --git a/src/NzbDrone.Core/Queue/QueueService.cs b/src/NzbDrone.Core/Queue/QueueService.cs index 8160da1f0..e33e79496 100644 --- a/src/NzbDrone.Core/Queue/QueueService.cs +++ b/src/NzbDrone.Core/Queue/QueueService.cs @@ -20,7 +20,7 @@ public interface IQueueService public class QueueService : IQueueService, IHandle { private readonly IEventAggregator _eventAggregator; - private static List _queue = new List(); + private static List _queue = new (); public QueueService(IEventAggregator eventAggregator) { @@ -92,8 +92,11 @@ private Queue MapMovie(TrackedDownload trackedDownload, Movie movie) 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()); }