From 5208f5e96602fd8ba2c277a0cde51daf8c8b1de8 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Fri, 31 Jan 2025 18:06:55 +0200 Subject: [PATCH] New: Refresh cache for tracked queue on series update --- .../TrackedDownloadService.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs index cc54dc1cb..d0c8b6deb 100644 --- a/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs +++ b/src/NzbDrone.Core/Download/TrackedDownloads/TrackedDownloadService.cs @@ -29,6 +29,8 @@ public interface ITrackedDownloadService public class TrackedDownloadService : ITrackedDownloadService, IHandle, IHandle, + IHandle, + IHandle, IHandle { private readonly IParsingService _parsingService; @@ -305,6 +307,38 @@ public void Handle(SeriesAddedEvent message) } } + public void Handle(SeriesEditedEvent message) + { + var cachedItems = _cache.Values + .Where(t => + t.RemoteEpisode?.Series != null && + (t.RemoteEpisode.Series.Id == message.Series?.Id || t.RemoteEpisode.Series.TvdbId == message.Series?.TvdbId)) + .ToList(); + + if (cachedItems.Any()) + { + cachedItems.ForEach(UpdateCachedItem); + + _eventAggregator.PublishEvent(new TrackedDownloadRefreshedEvent(GetTrackedDownloads())); + } + } + + public void Handle(SeriesBulkEditedEvent message) + { + var cachedItems = _cache.Values + .Where(t => + t.RemoteEpisode?.Series != null && + message.Series.Any(s => s.Id == t.RemoteEpisode.Series.Id || s.TvdbId == t.RemoteEpisode.Series.TvdbId)) + .ToList(); + + if (cachedItems.Any()) + { + cachedItems.ForEach(UpdateCachedItem); + + _eventAggregator.PublishEvent(new TrackedDownloadRefreshedEvent(GetTrackedDownloads())); + } + } + public void Handle(SeriesDeletedEvent message) { var cachedItems = _cache.Values